Unnecessary training on the final token in SFT
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.5k
- Forks
- 1.3k
- Avg merge
- 5h 36m
- Merged PRs (30d)
- 22
Description
Existing behavior: the model receives all tokens, and the last token is sliced out after the forward is run, in the above line.
The correct way:
tokens, a tensor of length 100, is received from the dataset
inputs, a tensor of length 99, consisting of tokens[:-1], is received by the model
logits, a tensor of length 99, is produced by the model.
Then the model handles 100-1 tokens, saving 1 token of context length.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read slime/backends/megatron_utils/loss.py at line 65 and compare the current forward inputs with the issue's 100-token and 99-token example. Trace how tokens and inputs reach the model, then verify that the model receives tokens[:-1], produces logits for the remaining positions, and avoids training on the final token.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100