Back to directory

Hands-on LLM: From Building It by Hand to Real Applications

A Chinese self-study path for LLMs that hand-implements a transformer in native PyTorch and runs pretraining, SFT, LoRA, DPO and GRPO on a single consumer GPU, then covers an industrial fine-tuning framework, agent engineering and a RAG system.

Hands-on LLM: From Building It by Hand to Real Applications

Hands-on LLM is a self-study and hands-on project path that goes from theory to a working system: Stanford's CS336 course material explained in Chinese, a from-scratch PyTorch and Triton implementation of a transformer, including a byte-level tokenizer, RMSNorm, RoPE, grouped-query attention and SwiGLU each checked numerically, a full five-stage training run of pretraining, SFT, LoRA, DPO and GRPO plus verifiable-reward reinforcement learning, a source-level walkthrough of the LLaMA-Factory fine-tuning framework, an agent-engineering module, and a medical-literature retrieval-augmented question-answering system.

All training experiments run on a single RTX 3080 Ti with 12 GB of VRAM, and the repository keeps the resulting numbers, curves, generated samples and problems encountered rather than only a finished write-up. Results include a 63.91-million-parameter model where doubling pretraining data lowered loss from 3.35 to 2.53; a LoRA adapter trained on 0.61 percent of parameters shrinking from 132 MB to 0.78 MB and cutting VRAM from 7.36 GB to 4.60 GB; a 300-step GRPO run under 22 minutes using a rule-based reward instead of a reward model; and a verifiable-reward run raising greedy accuracy on a held-out arithmetic test from 0.633 to 0.792.

It is aimed at people who already use these techniques as library calls but want to understand and reproduce them from first principles on a single GPU.

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.