Shift operation in loss computation for seq2seq model
Hello, I'm using the Seq2seqTrainer provided in Legacy here https://github.com/huggingface/transformers/blob/master/examples/legacy/seq2seq/seq2seq_trainer.py#L162 
I got a question when I read the `_compute_loss` function as it provides three different ways to calculate the loss.

In general, for text generation task, the labels and the logits need to be shifted before calculating loss for the purpose of predicting the next token.

**I wonder whether the methods in line 163 and in line 171 are lack of the shifting operation.** As the Seq2seqTrainer split the `labels` from the `inputs`, the model with `labels=None` will not compute the loss and will not shift the logits and labels in the `forward` function.
```
logits = model(**inputs, use_cache=False)[0] # no shift in the forward function
loss = self.loss_fn(logits.view(-1, logits.shape[-1]), labels.view(-1)) # no shift in the loss computation
```
While the method in line 168 will do the shift as the `labels` is provided to the `forward` function.

Do I understand right? Hopeful to get your advice.

- Text generation: @patrickvonplaten
- Trainer: @sgugger

Please note that this code is no longer maintained, so questions about it should be asked on the [forums](https://discuss.huggingface.co/) since we keep the issues for bugs and feature requests only.

As for your question, I'm not sure why you want to shift labels in a sequence-to-sequence problem. This Trainer is used for problems like summarization and translation, where there is no label shifting. If you want to apply it to a causal LM problem, you will need to shift your labels before sending them to the model.<|||||>Thanks for your fast reply. 
Sorry for asking my question in the wrong place. I've opened a topic on the [forums](https://discuss.huggingface.co/t/seq2seq-loss-computation-in-trainer/10988).
As for your reply, I don't understand why there is no need for shifting in seq2seq problem. The decoder inputs and the labels are identicals. I think that the labels need to be shifted by one position, because we need to predict the next token referring to the decoder inputs.
Perhaps we could further discuss this question on the [forums](https://discuss.huggingface.co/t/seq2seq-loss-computation-in-trainer/10988)?<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.