What is the difference between an encoder-decoder transformer and decoder-only transformer with regard to the loss calculation. Specifically, how does the loss signal differ? And how does this relate to token efficiency?
As far as I understand, an encoder-decoder model is composed of an encoder and a decoder. The output of the first is fed as queries and keys into a second multi-head attention layer of the decoder part. The input to the encoder is the input sequence. The input to the decoder is the target sequence, shifted right by one, and the output is a probability distribution over the tokens.
A decoder-only model is basically the same minus the multi-head attention layer that takes the encoder as input. Hence, as far as I understand, the inputs and outputs to the decoder-only model are identical to the encoder-decoder model's decoder.
When training a decoder-only model, I am given a sequence of, say, 4097 tokens. The first 4096 tokens are my input sequence, the last 4096 tokens my target labels. That way, the model will relate each token to its successor in the sequence. So, when training, will I calculate the loss signal of 4096 tokens at the same time? Shouldn't this be identical to the encoder-decoder model?