Back to directory

Happy-LLM

A systematic, free tutorial that teaches how large language models work by building one from scratch, from NLP and Transformer fundamentals through pretraining, fine-tuning, RAG, agents and reinforcement learning.

Visit website (opens in a new tab)datawhalechina.github.io
Happy-LLM

Happy-LLM is organized as eight chapters plus supporting material: an introduction to NLP basics, the Transformer architecture and attention mechanism built by hand, a comparison of encoder-only, encoder-decoder and decoder-only pretrained language models, and the general characteristics and training strategy of large language models. Later chapters have the reader implement a LLaMA2 model and its tokenizer and pretrain a small model, then cover the full training pipeline of pretraining, supervised fine-tuning and parameter-efficient methods such as LoRA and QLoRA, followed by applications including model evaluation, retrieval-augmented generation and agents, and a chapter on agentic reinforcement learning methods including GRPO, OPD and Search-R1.

It is aimed at university students, researchers and other LLM learners with some Python programming background, ideally with prior exposure to deep learning and NLP concepts. The book is distributed free, with an online reading version, a downloadable PDF, companion slides, and small pretrained and fine-tuned example models.

It is delivered mainly as Jupyter notebooks.

More in Tutorials

See all 478
  • BootLife

    github.com

    Conway's Game of Life implemented to run directly from a 512-byte x86 boot sector in assembly, using VGA memory itself as the simulation grid.

  • A technical blog post deriving the Y combinator as a composition of combinator birds in an array language, and examining how eager evaluation changes fixed-point recursion compared with the usual lazy telling.

  • System Design Atlas

    atlas-sysdes.vercel.app

    A free reference of worked system design problems with interactive architecture diagrams, covering ranked designs such as a feed, a chat app, a URL shortener, and a rate limiter, plus pages on the technologies behind them.