A hands-on, beginner-friendly series of Jupyter notebooks that teaches how Large Language Models work — from raw text all the way to the full Transformer architecture.
Every concept is built from scratch first, then shown with real-world libraries.
| # | Topic | Key Concepts |
|---|---|---|
| 1 | Tokenization | Character, Word, BPE, tiktoken, HuggingFace |
| 2 | Vectorization | Integer Encoding, One-Hot, Bag of Words, TF-IDF |
| 3 | Embeddings | Co-occurrence, SVD, Word2Vec, Sentence Transformers |
| 4 | Attention Mechanism | Scaled Dot-Product, Self-Attention, Multi-Head, BERT |
| 5 | Transformer Architecture | Positional Encoding, FFN, LayerNorm, Encoder, Decoder, GPT-2 |
Raw Text
│
▼
┌─────────────────┐
│ Tokenization │ "Hello world" → ["Hello", "world"]
└────────┬────────┘
│
▼
┌─────────────────┐
│ Vectorization │ ["Hello", "world"] → [0, 1] (integer IDs)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Embeddings │ [0, 1] → [[0.2, -0.5, ...], [0.8, 0.1, ...]]
└────────┬────────┘
│
▼
┌─────────────────┐
│ Attention │ each token looks at every other token
└────────┬────────┘
│
▼
┌─────────────────┐
│ Transformer │ stack of attention + FFN blocks → output
└─────────────────┘
1. Clone the repository
git clone <repo-url>
cd llm-series2. Create a virtual environment
python -m venv .venv3. Activate the virtual environment
On macOS / Linux:
source .venv/bin/activateOn Windows:
.venv\Scripts\activateYou should see (.venv) at the start of your terminal prompt — that means the environment is active.
4. Install dependencies
pip install -r requirements.txt5. Launch Jupyter
jupyter notebookOpen any notebook from its folder and run the cells top to bottom.
Tip: To deactivate the virtual environment when you are done, just run
deactivate.
- Basic Python (loops, functions, classes)
- No prior ML or NLP experience needed
llm-series/
├── 01-tokenization/
│ └── tokenization.ipynb
├── 02-vectorization/
│ └── vectorization.ipynb
├── 03-embeddings/
│ └── embeddings.ipynb
├── 04-attention-mechanism/
│ └── attention_mechanism.ipynb
├── 05-transformer-architecture/
│ └── transformer_architecture.ipynb
├── requirements.txt
└── README.md
- Character, word, and BPE tokenizers
- Integer encoder, one-hot encoder, Bag of Words, TF-IDF
- Co-occurrence matrix and SVD-based embeddings
- Cosine similarity search
- Scaled dot-product attention
- Multi-head attention
- Positional encoding
- Feed-forward network and layer normalization
- Encoder block, decoder block, full Transformer
| Library | Used for |
|---|---|
numpy |
All from-scratch implementations |
matplotlib |
Visualizations and heatmaps |
tiktoken |
GPT-style tokenization |
transformers |
BERT, GPT-2, tokenizers |
torch |
Model inference |
gensim |
Word2Vec training |
sentence-transformers |
Sentence embeddings |
scikit-learn |
PCA, t-SNE, TF-IDF |