r/learnmachinelearning • u/sakibbai • 5h ago
Coded a GPT2 Model using Python and Pytorch without Vibecoding
I have been building an LLM from scratch for learning purposes. Reading about transformers and LLMs never really scratched an itch that I have had. So, I started building one, without any vibe-coding. This is all "organic" code. With so much AI assisted coding, it is a nice change of pace.
The screenshot shows an output of a GPT2 model's output with an input prompt "I am hungry". The model has been pretrained on 20 public domain books for 10 epochs. It took around 50 minutes to train and the output looks quite real and non-giberish, right? Very iInteresting
Shout out to, Sebastian Raschka, PhD, as his resources really helped clear up things. Maybe later, I'll share a more in-depth idea about what I learned.
Link to the notebook : https://www.kaggle.com/code/sakibbai/building-a-basic-gpt2-from-scratch