bahree/ModelAdaptationBook
1
1---2license: apache-2.03base_model: Qwen/Qwen3-4B-Instruct-25074library_name: peft5tags:6- lora7- sft8- dpo9- knowledge-distillation10- fine-tuning11- it-support12---13 14# Model Adaptation Book — companion models15 16Trained artifacts for the book *LLM Customization and Fine-Tuning: Adaptation,17Distillation, and Alignment* (Manning). Code:18https://github.com/bahree/ModelAdaptationBook19 20All are adaptations of `Qwen/Qwen3-4B-Instruct-2507` on a real IT-support21dataset: Stack Exchange IT Q&A (Super User, Ask Ubuntu, Server Fault;22CC-BY-SA-4.0) plus a small Databricks Dolly slice (CC-BY-SA-3.0) for23general-capability retention. Each chapter's artifact is a **subfolder**, so you24can follow along on any machine (including Apple Silicon) by pulling a trained25model and running inference/eval, without training it yourself.26 27| Subfolder | Chapter | What | Base |28|---|---|---|---|29| `ch5-lora` | 5 | LoRA adapter | Qwen3-4B-Instruct-2507 |30| `ch6-sft` | 6 | full SFT model (standalone) | (full fine-tune) |31| `ch7-distilled` | 7 | distilled student (LoRA) | Qwen3-4B-Instruct-2507 |32| `ch8-dpo` | 8 | full DPO model (standalone) | (full fine-tune) |33| `ch8-dpo-lora` | 8 | LoRA-DPO adapter (single-card path) | `ch6-sft` |34 35Load a full model:36 37```python38from transformers import AutoModelForCausalLM39m = AutoModelForCausalLM.from_pretrained("bahree/ModelAdaptationBook", subfolder="ch6-sft")40```41 42Load an adapter (on its base):43 44```python45from transformers import AutoModelForCausalLM46from peft import PeftModel47base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Instruct-2507")48m = PeftModel.from_pretrained(base, "bahree/ModelAdaptationBook", subfolder="ch5-lora")49```50 51**Training** these needs a CUDA 24 GB+ GPU (and the Ch8 full DPO uses multiple52GPUs; the `ch8-dpo-lora` adapter is the single-card alternative). **Inference53and evaluation** fit a single smaller GPU or Apple Silicon (MPS). See the book54repo for exact commands, datasets, and full attribution.55 