inside def run_epoch() there is a call to model forward, that uses as argument…
- User
inside def run_epoch()
there is a call to model forward, that uses as argument "batch.tgt" the fact is that batch.tgt = tgt[:, :-1] I'm trying to understand why tgt[:, :-1] isntead of tgt[:, :]
Assistant
This is done because the model is likely trained using teacher forcing.
Teacher forcing is a technique where the target sequence used to calculate the loss is shifted by one timestep. So instead of using:
tgt = [1, 2, 3, 4, 5]
You use: tgt = [1, 2, 3, 4]
And the model is trained to predict the next token (5) based on the first four tokens.
This is done because if you used the full tgt sequence, the model could just memorize the input sequence, instead of actually learning to generate the next token from the previous context.
So tgt[:, :-1] takes all elements of tgt except the last one. This is then fed as input to the model, and the model is trained to predict tgt[:,-1] - the last element.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.