
gittech. site
for different kinds of informations and explorations.
But How Does GPT Actually Work? A Step-by-Step Notebook
π§ Train a Small GPT-Style LLM from Scratch
π This repository contains a Jupyter Notebook that trains a small GPT-style, decoder-only language model from scratch using PyTorch.
π Open the Notebook
π Overview
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
π Repository Structure
π gpt-from-scratch
βββ π README.md # Project documentation (this file)
βββ π llm-from-scratch.ipynb # Jupyter Notebook with full training pipeline
π Getting Started
1οΈβ£ Clone the Repository
git clone https://github.com/kevinpdev/gpt-from-scratch.git
cd gpt-from-scratch
2οΈβ£ Install Dependencies
Make sure you have Python and Jupyter installed. Install required packages:
pip install torch transformers datasets jupyter tiktoken
3οΈβ£ Run the Notebook
Launch Jupyter Notebook:
jupyter notebook
Open llm-from-scratch.ipynb and run
π― Goals & Use Cases
β
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 & Resources
π 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