Build Your Own LLM, Lesson 5: Self-Attention From Scratch
Understand and code the attention mechanism behind transformers: queries, keys, values, the causal mask and softmax — first with NumPy on four tokens, then…
Read article →Artificial intelligence explained by building it: machine learning, neural networks, LLMs, RAG and agents — plus how to build your own language model.
Understand and code the attention mechanism behind transformers: queries, keys, values, the causal mask and softmax — first with NumPy on four tokens, then…
Read article →Rebuild the bigram model as a neural network in PyTorch, train it with gradient descent, and add embeddings — the vectors that let language…
Read article →Build a bigram language model with plain Python dictionaries, generate text from it, and measure it with loss — the same number every LLM…
Read article →Build the byte-pair encoding tokenizer used by GPT-style models from scratch in about 40 lines of Python: training merges, encoding, decoding and why the…
Read article →A plain-English tour of what happens inside ChatGPT-style models: tokens, probabilities, training on next-token prediction, and why a model that only guesses the next…
Read article →Step-by-step guide to retrieval-augmented generation in Python: load PDFs and Excel sheets, chunk them, create embeddings, search by meaning, and answer with a local…
Read article →What people mean by AI agents: a model in a loop that can call tools such as search, a calculator or your database. How…
Read article →How LoRA fine-tuning works, why it trains less than 1% of a model’s parameters, when fine-tuning beats prompting or RAG, and a minimal Hugging…
Read article →AI assistants are great at Excel formulas — when you give them the right details and test the result. A five-step checklist with an…
Read article →Install Ollama, run open models like Llama and Qwen locally, call them from Python and Excel-friendly scripts, and create a custom model with a…
Read article →LLM "hallucinations" explained simply: why a next-token predictor can sound confident and still be wrong, and six practical habits to catch fabricated facts, formulas…
Read article →What the temperature and top-p settings in AI models actually do, with a worked numeric example, and which values to use for code, data…
Read article →