Laboratory track
The syllabus asks for at least 40-50% hands-on work. These fourteen labs reuse the code you already download with each unit; only Lab 1 and Lab 6 needed new material. The Colab notebooks were written without GPU or internet access and have not been executed by the author; the NumPy code runs offline and is tested.
Introduction to the Hugging Face / LLM ecosystem
Goal. Load a tokenizer and a small model, generate text, read a model card, load a dataset.
Needs. Unit 3. Files. Lab 1 notebook (new)
- Open the Lab 1 notebook in Colab (CPU is enough).
- Predict the tokens of 'unbelievable' before running the tokenizer cell.
- Generate at two temperatures and compare with Unit 3.
Check yourself
Tokenization and embeddings
Goal. Train a small BPE tokenizer and turn text into vectors you can compare.
Needs. Unit 3. Files. Unit 3 code zip (tokens_decoding), Unit 5 code zip (rag_np)
tokens_decoding.train_bpe(text, 50)thenencode(...): watch merges grow.rag_np.Tfidfandrag_np.LSA: embed sentences and compare by cosine similarity.- Open the Unit 3 tokenizer widget in the playground.
Check yourself
Implement self-attention
Goal. Compute scaled dot-product attention by hand and check it against the module.
Needs. Unit 2. Files. Unit 2 code zip (transformer_np)
- Read
transformer_np.attention(Q, K, V, mask)(6 lines). - Apply
causal_mask(n)and confirm the upper triangle of the weights is zero. - Without positions, permuting the input tokens only permutes the output rows; add
sinusoidal_pe(n, d)and show that this is no longer true.
Check yourself
Use a pretrained LLM
Goal. Prompt a real small model and watch decoding settings change the output.
Needs. Unit 4. Files. Unit 4 Colab notebook
- Open the Unit 4 Colab notebook.
- Run one prompt at three temperatures; record the outputs.
- Compare with
tokens_decoding.sampleon the toy distribution from Unit 3.
Check yourself
Prompt engineering experiments
Goal. Compare prompt variants with a measured, not guessed, result.
Needs. Unit 4. Files. Unit 4 code zip (prompting_tools)
- Build prompts with
renderandfew_shot_messages. - Score variants over the same questions; report with
paired_bootstrap_ci. - Make the output machine-readable with
structured_calland a schema.
Check yourself
Build an LLM chatbot
Goal. A multi-turn chatbot that trims history to the context window and pins what must stay.
Needs. Unit 4. Files. Lab extras zip (chatbot_np, new)
python codes/chatbot/chatbot_np/example_basic.py(offline, mock model).- Shrink
windowuntil old turns drop; checklast_dropped. - Wrap a real API client in a class with
complete(messages)and swap it in.
Check yourself
Build a PDF / document Q&A system
Goal. Chunk documents, retrieve the best chunks, and answer from them with citations.
Needs. Unit 5. Files. Unit 5 code zip (rag_np)
load_corpus, thenchunk_corpus(corpus, 200, overlap=40).- Rank with
BM25; build the answer withbuild_contextandextractive_answer. - To use your own PDF, extract the text first (for example with
pypdf) and put it indata/.
Check yourself
Implement RAG with a vector database
Goal. Replace brute-force search with an index and fuse two rankers.
Needs. Unit 5. Files. Unit 5 code zip and Colab notebook
- Build an
IVFindex;searchalso returns the number of distance computations. Compare recall and that count with exhaustive search for severalnprobe. - Fuse BM25 and LSA rankings with
rrf. - In the Unit 5 Colab notebook, repeat with a real embedding model and FAISS.
Check yourself
Fine-tune a small LLM with LoRA / QLoRA
Goal. See why a low-rank update is enough, then tune a real small model.
Needs. Unit 6. Files. Unit 6 code zip and Colab notebook
adapt_np.lora_fraction(d_out, d_in, r)for several r.fit_low_rank_gdversustruncated_svd_error: how close does gradient descent get?- Unit 6 Colab notebook: LoRA on a small model with
peft.
Check yourself
Build an image / text multimodal application
Goal. Embed images and text in one space and sample from a diffusion model.
Needs. Unit 7. Files. Unit 7 code zip and Colab notebook
- Train the CLIP-style toy with
train_clip, project withembed, and measure image-to-text retrieval. - Sample with
sample_ddimat 5, 10 and 50 steps. - Unit 7 Colab notebook: real vision-language models.
Check yourself
Build an LLM agent with tools
Goal. Run a reason-act loop with a tool registry and see where it fails.
Needs. Unit 8. Files. Unit 8 code zip and Colab notebook
scripted_run(kind, params), then inject a failure withfail_at.- Add
make_verifierand compare success rates withwilsonintervals. - Test
defendagainst the injected text inattack_outcome.
Check yourself
Evaluate hallucination and RAG quality
Goal. Measure retrieval quality and answer groundedness on the same questions.
Needs. Unit 9. Files. Unit 9 code zip and Colab notebook
rag_np.evaluatefor recall at k.evaluation_np.grounded_scoreper answer sentence; flag unsupported ones.- Compare two judges with
cohen_kappa.
Check yourself
Deploy an LLM application
Goal. Serve the RAG retriever behind an HTTP API and measure it.
Needs. Unit 10. Files. Unit 10 code zip and Colab notebook
- Install
fastapi uvicorn requests pydantic. uvicorn app_fastapi:appthen POST to/ask; GET/health.python bench_service.pyfor latency under concurrent load.
Check yourself
Capstone project
Goal. Combine retrieval, an agent loop, evaluation and a service into one application.
Needs. Unit 11. Files. Unit 11 (capstone) notes and code
- Read Unit 11, pick a brief, build the minimum version first.
- Evaluate before you tune.
- Write the report using the template.
Check yourself
What the numbers do and don’t show
- The Lab 1 notebook and all the Colab notebooks are written but not executed (no GPU or internet where the course was built).
- Unit 11 has no language model in it: its generator quotes a sentence. With 20 answerable and 6 unanswerable questions, a threshold tuned on one half answered 1 of 3 unanswerable questions on the other half, which the Unit 11 PDF reports. Its rates rest on very few questions.
- The assessment short answers are model answers, and the papers are the author’s own samples, not past papers.
Not covered yet
An optional advanced appendix (RLHF and DPO, rotary position embeddings, FlashAttention, speculative decoding, HNSW) has not been written. The lab list on this page is generated from the course source rather than listed as separate curriculum nodes.