Skip to main content
Join the community, learn LLM together →

Deeply Understand Large Language Models

We are training an LLM from scratch, and every step goes into this course: why we did it, what we traded off and where it went wrong.

Intelligence

Context

  1. Int1072
  2. elligence8509
  3. ?

Next-token probabilities

  • is0.39
  • and0.22
  • in0.11
  • ,0.07
  • as0.05

Math, code and a figure you can touch

Read the chapter →

Encode position as a rotation angle, and the dot product only sees the relative distance m−n.

q′=q⊙cos⁡(mθ)+rotate_half⁡(q)⊙sin⁡(mθ)\textcolor{blue}{q'} = \textcolor{blue}{q} \odot \cos(\textcolor{blue}{m\theta}) + \operatorname{rotate\_half}(\textcolor{blue}{q}) \odot \sin(\textcolor{blue}{m\theta})
02_rope.py
def rotate_half(x):
    x1 = x[..., : x.shape[-1] // 2]
    x2 = x[..., x.shape[-1] // 2 :]
    return torch.cat((-x2, x1), dim=-1)

q_embed = (q * cos) + (rotate_half(q) * sin)
k_embed = (k * cos) + (rotate_half(k) * sin)
3
1
15°
(m−n)θqkmθnθ

Curriculum

Fundamentals

Six parts, from the basics to agents

Code in the cookllm-recipes repo, runnable as you read

Start Learning →
  1. 01BasicsTokenization, Transformer, optimization
  2. 02Systems and deploymentGPU kernels, parallelism, inference and serving
  3. 03Scale and dataScaling laws, cleaning, dedup, mixing
  4. 04EvaluationBenchmarks, parsing, reliability
  5. 05Post-trainingSFT, RLHF, GRPO, DPO
  6. 06Multimodal and agentsVision, image-text alignment, tool use
Hands-on Training

Six stages, from data to an agent

Code in the cookllm-bento repo, trained in public

View experiments →
  1. 01Data prepDownload, Clean, Pack
  2. 02Tokenizer trainingRustBPE, tiktoken
  3. 03Model buildBentoLM, RoPE, Muon
  4. 04PretrainingMuon, WSD, Scaling
  5. 05MidtrainingLong context, RoPE scaling
  6. 06Post-training and agentsSFT, RL, tool use

More chapters on the way. Stay tuned.

Pricing

CookLLM logo

Course lifetime

The course is still being built: early price

$99$69

Pay once, yours for good

  • Every chapter, now and to come
  • All the course repo code
  • Interactive figures you can tweak in each chapter
  • Hands-on training: six stages, from data to an agent
  • Every BentoLM experiment record
  • The video course when it launches

What you might want to know

Start deeply understanding large language models today