🚀 This repository contains a Jupyter Notebook that trains a small GPT-style, decoder-only language model from scratch using PyTorch.
This project is an educational walkthrough of the process of building and training a Minimal GPT-style Decoder Only Transformer Model. The notebook covers:
- 📖 Tokenization – Converting text into tokens
- 🔄 Positional Encoding – Adding order to input sequences
- 📈 Self Attention Intuition - Building intuition behind the self attention operation
- 🏗 Transformer Decoder Blocks – Multi-head self-attention & feedforward layers
- 🎯 Training from Scratch – Using a small pretraining and SFT dataset to train a language model
- 🔥 Inference – Generating text using the trained model
📂 gpt-from-scratch
│── 📄 README.md # Project documentation (this file)
│── 📒 llm-from-scratch.ipynb # Jupyter Notebook with full training pipeline
git clone https://github.com/kevinpdev/gpt-from-scratch.git
cd gpt-from-scratch
Make sure you have Python and Jupyter installed. Install required packages:
pip install torch transformers datasets jupyter tiktoken
Launch Jupyter Notebook:
jupyter notebook
Open llm-from-scratch.ipynb and run
✅ Understand dataset formats and working with Huggingface libraries
✅ Learn the process of tokenization
✅ Learn the inner workings of GPT-style models
✅ Train a small-scale Transformer on a custom dataset
✅ Understand self-attention and language modeling
✅ Experiment with fine-tuning & inference
📌 Notebook: llm-from-scratch.ipynb
📖 Transformer Paper: “Attention Is All You Need"
📖 GPT Paper: "Improving Language Understanding by Generative Pre-Training"
🛠 PyTorch Documentation: pytorch.org
👐 Huggingface Documentation: https://huggingface.co/docs