Issues with se2seq tutorial (batch training)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9.3k
- Forks
- 4.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 4
Description
Add Link
Link to the tutorial:
https://pytorch.org/tutorials/intermediate/seq2seq_translation_tutorial.html
Describe the bug
The tutorial was markedly changed in June 2023, see commit 6c03bb3bbe17100a3b45e0c92c564911e24ab796 which aimed at fixing the implementation of attention among other things (#2468). In doing so, several other things have been changed:
- adding dataloader which returns a batch of zero-padded sequences to train the network
- the
foward()function of the Decoder process input one word at the time in parallel for all sentences
in the batch until MAX_LENGTH is reached.
I am not a torch expert but I think that the embedding layers in the encoder and decoder should have been modified to recognize padding (padding_idx=0 is missing). Using zero-padded sequence as input might also have other implications during learning but I am not sure. Can you confirm that the implementation is correct?
As a result of these change, the text does not describe well the code. I think that it would be nice to include a discussion of zero-padding and the implications of using batches on the code in the tutorial. I am also curious if there is really a gain in using a batch since most sentences are short.
Finally, I found a mention in the text about using teacher_forcing_ratio which is not included in the code. The tutorial or the code need to be adjusted.
If this is useful, I found another implementation of the same tutorial which seems to be a fork from a previous version (it was archived in 2021):
- It does not does not use batches
- It includes
teacher_forcing_ratioto select the amount of forced teaching - It implements both Luong et al and Bahdanau et al. models of attention
Describe your environment
I appreciate this tutorial as it provides a simple introduction to Seq2Seq models with a small dataset. I am actually trying to port this tutorial in R with torch package.
cc @albanD
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
Start with the seq2seq translation tutorial and compare the current code with commit 6c03bb3bbe17100a3b45e0c92c564911e24ab796. Review the encoder and decoder embedding layers, batched zero-padding flow, and the mention of teacher_forcing_ratio. Done means confirming the implementation and aligning the tutorial text or code with the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100