When generating, the previous output is the next input, however when training, the correct output is the next input. This training technique is known as “teacher forcing” - look that up for more on why it’s used.