14. Phase 12 — Multimodal AI, Fine-Tuning & Open Models

These are important, but learn them after the core stack.

14.1 Multimodal AI

Definition. A multimodal model accepts and/or produces more than one type of content — text, images, audio — within a single architecture, rather than requiring separate specialized models glued together. Document intelligence in particular often combines several techniques from earlier chapters: OCR/layout extraction (Chapter 7's ingestion step) feeding into a vision-capable model, whose output is then constrained by the structured-output pattern (Chapter 5).

14.2 Fine-Tuning: When to Use It

🚧 Fine-tuning is not the default solution Fine-tuning is not the default solution for missing current facts or private documents. Those are usually retrieval/tool problems (Chapters 7–8). Fine-tuning is more useful for behavior/style/task specialization, structured patterns, domain-specific classification/extraction or improving smaller models when you have high-quality labeled examples.

Before Fine-Tuning, Try

This ordered checklist reflects a real cost/complexity hierarchy: prompting and structured outputs are cheap to iterate on; RAG and tool calling require moderate engineering; fine-tuning requires labeled data, training infrastructure, and evaluation before/after — the most expensive option, reserved for when cheaper approaches provably fail.

14.3 Fine-Tuning Topics

Prerequisite Concept — LoRA/QLoRA (Conceptual)

Definition. Full fine-tuning updates all of a model's (potentially billions of) parameters, requiring significant compute and memory. LoRA (Low-Rank Adaptation) instead freezes the original weights and trains small additional "adapter" matrices inserted into the model, dramatically reducing the number of trainable parameters and the compute/memory needed. QLoRA combines this with quantization (representing the frozen base weights in lower precision) to further reduce memory requirements, making fine-tuning feasible on much more modest hardware.

Catastrophic Forgetting

Definition. A risk where fine-tuning a model heavily on a narrow new task degrades its previously good performance on other, unrelated tasks/knowledge — the model "forgets" general capability while specializing. This is one reason evaluation before and after fine-tuning (on both the target task and a broader capability check) is listed as mandatory.

14.4 Open-Weight / Local Models

Hosted vs Open-Weight — Comparison

AspectHosted proprietary APIOpen-weight / self-hosted
InfrastructureNone — managed by providerYou manage GPUs/serving infrastructure
Data controlDepends on provider's retention policyFull control; data never leaves your environment
Fine-tuning flexibilityLimited to provider's fine-tuning API, if offeredFull control over training process
Cost modelPay per token/callPay for infrastructure regardless of usage (until scale favors it)
Operational burdenLowHigh — serving, scaling, monitoring all your responsibility
⚠️ Common Mistake Trusting public leaderboard rankings as a proxy for how a model will perform on your specific task. Public benchmarks measure general capability on their own test distributions; your production task may stress entirely different skills (e.g. following a narrow extraction schema) where leaderboard rank and real task performance diverge significantly. Always benchmark candidates on your own eval set (Chapter 11).

14.5 PyTorch Depth for Applied AI

Know tensors, devices, model loading/inference, basic training loops and how to read model code. Go deeper into optimization, distributed training, CUDA and model architecture only if you want to move toward ML Engineering or model training (see Chapter 22, Option C).

Common Questions

Q: When is fine-tuning actually the right call?
When the problem is genuinely about behavior/style/format specialization or classification on a narrow domain with high-quality labeled data — not when the problem is missing current facts or private documents, which RAG solves more cheaply and updatably.
Q: What's the practical benefit of LoRA over full fine-tuning?
It trains a small number of additional parameters instead of the full model, drastically cutting compute/memory requirements while still adapting model behavior meaningfully for many tasks.
Q: Why benchmark an open-weight model on your own eval set instead of trusting a public leaderboard?
Leaderboards measure general capability on their own benchmarks, which may not reflect performance on your specific task/schema/domain — only your own eval set tells you how the model will actually perform in your product.

Interview / Viva Questions

Q: Give two reasons fine-tuning is not the default fix for "the model doesn't know our internal data."
Fine-tuning is slow and expensive to update whenever data changes, and it does not reliably teach discrete new facts the way retrieval does — RAG keeps knowledge external, current, and citable.
Q: What is catastrophic forgetting, and how do you guard against it?
It's the degradation of a model's general/prior capabilities after aggressive fine-tuning on a narrow task; guard against it by evaluating both the target task and broader capability before and after tuning, and by preferring parameter-efficient methods (LoRA) that touch fewer weights.
Q: What trade-off does choosing a self-hosted open-weight model involve?
Greater control over data privacy and fine-tuning flexibility, at the cost of owning all serving/scaling/monitoring infrastructure that a hosted API provider would otherwise manage.

Chapter Summary