I am learning the transformers architecture from these two sources:
https://arxiv.org/pdf/1706.03762.pdf
https://jalammar.github.io/illustrated-transformer/
I just wanted to ask about the final step in the decoder. Let's fix testing time. As I understand, the decoder starts with an input of dimension $(N_{words},d_{emb})$, where $N_{words}$ is the number of words already predicted and $d_{emb}$ is the embedding dimension.
Now if we "follow" the following decoder steps, at each step (after e.g. the attention layers) we should have a vector of dimension $(N_{words},d_{model})$ where $d_{model}$ is the model dimension. In other words, up to the final linear layer we have $N_{words}$ vectors which are $d_{model}$-dimensional.
Are all these $N_{words}$ vectors fed into the last linear layer (before the softmax) or, as I suspect, only the last of these vectors is used ? In the latter case the last linear layer would be a matrix of dimension $d_{model}\times N_{vocab}$, where $N_{vocab}$ is the vocabulary dimension.
Is this correct ? Are there any issues in what I wrote ? Unluckily from the online sources I was not able to clarify this point...
PS: I conjectured that the last linear layer is using just the last vector, because than I would understand what happens in training time, one would just use in that case all the output vectors from the decoder, instead of just the last one, to have a parallelized prediction.