Verification of script to train a LLM on supervised data

Trainer does sound like a great tool but I noticed that it lags in speed as compared to the manual loop as it has a lot of stuff built on top of the loop. Also writing a manual loop provides a sense of control over the training. As far as errors are concerned, the script runs well :face_exhaling:. Also HuggingFace doesn’t provide a tutorial for supervised fine-tuning using Trainer from transformers (only a trl based SFTTrainer tutorial is provided). The script I provided tries supervised finetuning using transformers. Also HuggingFace tutorials are not up-to-date with the stable versions of the modules it uses which leads to a lot of errors and debugging sessions on my part. Due to this reason, I try manually doing stuff like the tokenization, data loading, training loop, etc. Can you help me out with the tokenization part and help me figure out my mistake?

1 Like