How LLMs Work by Андрей Сапунов

How LLMs Work

By

Description

Everyone uses large language models. Almost no one knows what's inside. This book is the answer to the quiet question every ChatGPT user eventually asks: how does this thing actually work? Starting from "what even is this?", it walks you — rung by rung — all the way to writing and training your own small GPT, one line of code at a time. No hand-waving, no "it's complicated math, just trust us." The core ideas would fit on a napkin, and this book shows you every one of them. It's really two books in one. Read the main text and you'll come away with a solid, honest intuition: what tokens, embeddings, attention, and training really are, why models "hallucinate," and how to use them well. Follow the engineering asides — with real formulas and code — and you'll leave able to build a transformer from scratch. By the end, you'll be able to: • Explain LLMs, tokens, embeddings, and attention in plain words. • Read the famous "Attention Is All You Need" transformer diagram without fear. • Write and train a real (if tiny) language model in Swift, line by line. • Use LLMs deliberately — understanding hallucinations, prompting, RAG, and agents. • See past both the hype and the panic. Every code example is real, runnable Swift (pure Swift and Apple's MLX) — tested on a Mac, not pseudocode. Whether you're a curious beginner, a developer who wants to stop treating AI as magic, or a student of the field, this is the gentle-but-rigorous guide that takes the magic apart into gears — and shows there was never anything magical inside. Just very, very many multiplications.

More Андрей Сапунов Books