A hands-on educational project for understanding and implementing Large Language Models (LLMs) from scratch. This project provides implementations of GPT-2 and related techniques, making it an excellent resource for learning about transformer architectures and modern language models.
Features
GPT-2 Implementation
A clean, educational implementation of GPT-2 with type hints, supporting both training and inference.
Speculative Sampling
An implementation of speculative sampling for faster inference, featuring configurable draft models and performance benchmarking.
KV Cache Optimization
A memory-efficient GPT-2 implementation with KV cache optimization for handling longer sequences.
Quick Start
Prerequisites
Python 3.11 or 3.12
Git and Git LFS (for model files)
UV (recommended package manager)
Installation
Clone the repository:
bash
git clone https://github.com/ai-glimpse/toyllm.git
cd toyllm