You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f95e244
Browse filesBrowse the repository at this point in the historyBrowse files
Load a full model with `AutoModelForCausalLM.from_pretrained("bahree/ModelAdaptationBook", subfolder="ch6-sft")`, or an adapter with `PeftModel.from_pretrained(base, "bahree/ModelAdaptationBook", subfolder="ch5-lora")`. This is why the "What runs where" table marks chapters 6 to 8 as not running on Apple Silicon: that is about *training* them. You can still *use* their results on a Mac by pulling the trained model.
54
+
Load a full model with `AutoModelForCausalLM.from_pretrained("bahree/ModelAdaptationBook", subfolder="ch6-sft")`, or an adapter with `PeftModel.from_pretrained(base, "bahree/ModelAdaptationBook", subfolder="ch5-lora")`.
55
+
56
+
**The exact commands.** Every model or adapter path argument in the book's scripts also accepts a Hub reference of the form `repo#subfolder` (resolved by `common/hub.py`), so each chapter's evaluation and inference steps run from the published artifact with no local training run. Run from `code/` with the virtual environment active; the first run downloads the base model (about 8 GB) and the artifact, both cached afterwards, no token required. Quote the reference on shells where `#` starts a comment.
57
+
58
+
```bash
59
+
# Chapter 5: evaluate and run the published LoRA adapter (step 3 and step 5 of the chapter)
On Windows, replace the trailing `\` with `^` and keep the quotes around the Hub references. This is why the "What runs where" table marks chapters 6 to 8 as not running on Apple Silicon: that is about *training* them. You can still *use* their results on a Mac by pulling the trained model.
54
107
55
108
## GPU requirements at a glance
56
109
@@ -63,7 +116,7 @@ AMD (ROCm) was validated end-to-end on a datacenter card (Instinct MI300X); VRAM
63
116
| 3 (data-quality experiment) | same profile as chapter 5 LoRA | 8 GB | 12 GB+ | Yes | Synthetic-data pipeline yes; manifest module yes; full experiment slow | Yes, verified (bf16 LoRA on MPS); synthetic-data pipeline and manifest module also yes |
64
117
| 4 (ICL/RAG) | inference only (~8 GB for the optional HF backend) | None for mock backends; ~8 GB for the optional Qwen3-4B HF backend | 12 GB+ | Yes | Yes (mock backend / hash embedder) | Yes (mock backends are CPU; HF backend uses MPS, slow on 8 GB) |
| 5 (QLoRA, r=8) |**5.1 GB** allocated (5.4 GB reserved), one card | 6 GB | 8 GB+ | Yes (4-bit works; benign `rocminfo` warning) | Not recommended |**No** (`bitsandbytes` is CUDA-only; the published `ch5-qlora` adapter loads on the bf16 base for inference) |
67
120
| 6 (Full SFT) |**32.5 GB** total (17.2 + 15.3 GB across two A30s); **OOM on one A30** at 23.2 GB during AdamW state init | Two 24 GB cards (A30 / RTX 4090), or one 40 GB card | A100 40 GB+ | Yes | No | No |
68
121
| 7 (Distillation, LoRA student r=16) |**10.5 GB** allocated (15.8 GB reserved, batch 2), one card | 12 GB for the student; the teacher-generation stage loads the chapter 6 model for inference (~10 GB) | 24 GB+ | Yes | Not recommended | Student: yes in principle (LoRA on MPS); teacher generation is slow |
69
122
| 8 (DPO, full-parameter) |**54.3 GB** total (18.4 + 18.6 + 17.3 GB across three A30s); **OOM on two A30s** (23.2 + 22.7 GB) | Three 24 GB cards, or one 80 GB card | A100 80 GB / H100 | Yes | No | No |
The chapter's LoRA adapter is published as `bahree/ModelAdaptationBook#ch5-lora` (and the QLoRA adapter as `#ch5-qlora`); every `--adapter` argument below accepts that `repo#subfolder` form, so steps 3 to 5 run on any machine, including Apple Silicon, without a training run:
--prompt "Explain how photosynthesis works in simple terms."
230
+
```
231
+
232
+
The QLoRA adapter needs `--quantized_4bit` (CUDA only) to match training. See [ACCELERATORS.md](../../ACCELERATORS.md#running-without-training-pull-the-model-from-hugging-face) for every chapter's commands.
Copy file name to clipboardExpand all lines: code/chapter06/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,8 @@ Training time: ~10 min (2x A30, sharded), ~45-60 min (A100). A single 24 GB card
103
103
104
104
### Step 3: Generate a response (Listing 6.3)
105
105
106
+
> **No training GPU?** The chapter's SFT model is published as `bahree/ModelAdaptationBook#ch6-sft`; `--model_dir` accepts that `repo#subfolder` form, so `eval_sft` and `generate` run from the published model (for example `--model_dir "bahree/ModelAdaptationBook#ch6-sft"`). Commands for every chapter: [ACCELERATORS.md](../../ACCELERATORS.md#running-without-training-pull-the-model-from-hugging-face).
> **No training GPU?** The distilled student is published as `bahree/ModelAdaptationBook#ch7-distilled` and the teacher as `#ch6-sft`; `--teacher_dir`, `--student_dir`, and `--adapter_dir` accept that `repo#subfolder` form (for example `--adapter_dir "bahree/ModelAdaptationBook#ch7-distilled"`). Commands for every chapter: [ACCELERATORS.md](../../ACCELERATORS.md#running-without-training-pull-the-model-from-hugging-face).
417
+
416
418
```bash
417
419
python -m chapter07.generate \
418
420
--adapter_dir chapter07/runs/student_run1 \
@@ -497,12 +499,12 @@ The script writes a single JSON to `chapter07/runs/frontier_comparison.json` (or
497
499
498
500
### Reading the output
499
501
500
-
The chapter quotes the Ch6 SFT response (terse, generic) alongside Claude Sonnet 5.5's response (structured by category, with command examples and a follow-up question). The same gap will show up on most domain-specific prompts where you have an SFT model trained on a few hundred examples and the frontier model has been trained on the entire internet:
502
+
The chapter quotes the Ch6 SFT response (terse, generic) alongside Claude Sonnet 4.5's response (structured by category, with command examples and a follow-up question). The same gap will show up on most domain-specific prompts where you have an SFT model trained on a few hundred examples and the frontier model has been trained on the entire internet:
501
503
502
504
- If the frontier response is dramatically more thorough and specific, distillation has a clear quality target. The cost model in §7.3 then tells you whether the per-request economics justify it.
503
505
- If the responses are roughly comparable, your SFT model is already close to the ceiling for this task type and distillation may not move the needle. Save the budget for a different intervention (a better prompt, more training data, a different metric).
504
506
505
-
The Gemini 3.1 Pro response includes a `reasoning` field with the model's internal scratchpad; the `content` field is the user-facing answer. The chapter quotes only `content`; the JSON keeps both for audit.
507
+
The Gemini 2.5 Pro response includes a `reasoning` field with the model's internal scratchpad; the `content` field is the user-facing answer. The chapter quotes only `content`; the JSON keeps both for audit.
0 commit comments