
The rise of large language models (LLMs) has reshaped modern artificial intelligence. But how do they really work, and how can we build or fine-tune one ourselves? Andriy Burkov’s Mastering Language Models offers a uniquely approachable and deeply practical guide for anyone eager to understand and apply language modeling—from theory to PyTorch code.
A Personal Journey Into Language Modeling
The book begins with Burkov’s own journey, from his fascination with meaning in language to the breakthroughs of his PhD thesis, where neural language models outperformed n-grams—an idea once considered unthinkable. His narrative is both personal and inspiring, providing a sense of how ideas evolve into innovations that shape the field.
From First Principles to Transformers
Burkov doesn’t rush into the deep end. He builds up from the basics of machine learning, including supervised learning, loss functions like mean squared error, and gradient descent. With clarity and precision, he introduces feedforward neural networks, logistic regression, and ReLU activation—laying a solid foundation for the more advanced topics to come.
Crucially, he bridges the gap between the traditional bag-of-words model and modern neural approaches. From simple tokenization to embeddings and vector search engines, readers learn how to convert text into mathematical representations that machines can understand.
PyTorch: More Than Just Code
One of the book’s strengths is its seamless integration of theory and implementation. You’ll not only learn about tensors, gradients, and backpropagation—you’ll code them in PyTorch. The book offers extensive examples, including custom classifiers and end-to-end training pipelines. Even beginners can follow along thanks to the accessible writing and links to the book’s continuously updated wiki.
RNNs, Transformers, and Beyond
As the book progresses, Burkov dives into architectures like recurrent neural networks (RNNs) and then Transformers, explaining their mechanics in plain language. Concepts like self-attention, positional encodings, and residual connections are all unpacked thoughtfully.
A standout chapter explains how large context windows (up to 128,000 tokens) and massive parameter counts (hundreds of billions) empower today’s state-of-the-art models like GPT-3.5, Llama 3, and others.
Fine-Tuning, Embeddings, and Real-World Applications
Burkov also teaches how to fine-tune LLMs for practical tasks—like emotion classification and instruction-following—using tools like LoRA and libraries like Hugging Face’s transformers and peft. You’ll even explore advanced topics like:
- Evaluation metrics like perplexity and ROUGE
- Text generation strategies including top-k and top-p sampling
- Finetuning for dialogue (ChatML)
- Bias, overfitting, and hallucinations in LLMs
The book’s examples span academic and industrial relevance, from automatic documentation and summarization to emotion recognition and legal reasoning.
A Philosophy of Access
Perhaps most refreshingly, Burkov practices what he preaches. He distributes the book under a “read first, buy later” principle—believing that knowledge should be accessible before it’s monetized. If you find value in the book, you’re encouraged to support it.
In my case, I did just that.

Proof of Purchase
I chose to support Andriy Burkov’s mission by buying the book after reading the PDF version. Here’s a copy of my invoice, honoring the spirit of ethical knowledge-sharing and open learning.
Final Thoughts
Mastering Language Models is more than a technical manual—it’s a roadmap for anyone wanting to understand or build modern AI. Whether you’re a developer, data scientist, or ML researcher, this book will sharpen your understanding and expand your skills. Highly recommended as both a study guide and practical handbook.


*The views expressed here are my own and do not represent those of my employer.*
Hello, I’m Bruno — a dual citizen of Brazil and Sweden. I bring a global perspective shaped by experiences in both South America and Europe, with a strong focus on collaboration and innovation across cultures. I am a Computer Scientist, PhD Candidate in Information and Communication Technologies, focusing on Data Science and Artificial Intelligence, and hold dual Master’s degrees in Data Science and Cybersecurity. With over fifteen years of international experience spanning Brazil, Hungary, and Sweden, I have collaborated with global organizations such as IBM, Playtech, and Oracle, as well as contributed remotely to projects across multiple regions. My professional interests include Databases, Cybersecurity, Cloud Computing, Data Science, Data Engineering, Big Data, Artificial Intelligence, Programming, and Software Engineering, all driven by a deep passion for transforming data into strategic business value.