M6-032M6: Multimodal & Generative ModelsVLM Training & EvaluationEasy
⚡Flashcard Drill➔Mastery:

The Canonical Three-Stage Training Pipeline of Multimodal Large Language Models

📐 Mathematical Definition
stage1: train connector;stage2: unfreeze LLM;stage3: preference opt.\text{stage1}:\ \text{train connector};\quad \text{stage2}:\ \text{unfreeze LLM};\quad \text{stage3}:\ \text{preference opt.}
⚡ One-Sentence Core Answer
Modern VLMs are trained through a structured three-stage pipeline: pre-training connector alignment on paired image-text captions, visual instruction fine-tuning, and preference alignment via multimodal DPO.

📌 Key Takeaways

  • •
    Stage 1 (Pre-training Alignment): trains lightweight connector weights while freezing vision encoder and LLM on millions of diverse image-caption pairs
  • •
    Stage 2 (Visual Instruction Tuning): unfreezes the LLM (and optionally the vision tower) on high-quality multimodal instruction datasets spanning VQA, OCR, reasoning, and multi-turn chat
  • •
    Stage 3 (Preference Alignment / RLHF): applies Direct Preference Optimization (DPO) on paired chosen/rejected multimodal completions to suppress hallucinations and refine helpfulness

📐 Mathematical Derivations

Mathematical Mechanism: 1. Stage 1: Feature Alignment Pre-training: (a) Data: 500K to 10M image-caption pairs (CC3M, LAION filtered). (b) Status: Vision Tower θv\theta_v Frozen, LLM θllm\theta_{\text{llm}} Frozen, Connector ϕ\phi Trainable. (c) Objective: min⁡ϕ  E(I,X)[−∑t=1∣X∣log⁡P(xt∣x<t,gϕ(fv(I)))]\min_\phi \; \mathbb{E}_{(I, X)} \left[ - \sum_{t=1}^{|X|} \log P(x_t \mid x_{<t}, g_\phi(f_v(I))) \right] Aligns the connector's projection so visual tokens map into valid semantic neighborhoods of the LLM word embedding space. 2. Stage 2: Multimodal Instruction Fine-Tuning: (a) Data: 500K to 2M multi-task instruction pairs (LLaVA-Instruct, ShareGPT4V, DocVQA, MathVista). (b) Status: Connector ϕ\phi Trainable, LLM θllm\theta_{\text{llm}} Trainable, Vision Tower θv\theta_v Frozen / Low LR. (c) Objective: Standard autoregressive loss conditioned on conversation context and visual tokens. 3. Stage 3: Multimodal Direct Preference Optimization (MDPO): (a) Data: Pairs (I,x,yw,yl)(I, x, y_w, y_l) where ywy_w is accurate and yly_l contains visual hallucinations. (b) Objective: LMDPO(θ)=−E(I,x,yw,yl)[log⁡σ(βlog⁡πθ(yw∣I,x)πref(yw∣I,x)−βlog⁡πθ(yl∣I,x)πref(yl∣I,x))]\mathcal{L}_{\text{MDPO}}(\theta) = - \mathbb{E}_{(I, x, y_w, y_l)} \left[ \log \sigma \left( \beta \log \frac{\pi_\theta(y_w \mid I, x)}{\pi_{\text{ref}}(y_w \mid I, x)} - \beta \log \frac{\pi_\theta(y_l \mid I, x)}{\pi_{\text{ref}}(y_l \mid I, x)} \right) \right] Penalizes responses that assert the existence of non-existent visual entities.

🏭 Production Trade-offs

Deep Dive & Engineering Trade-offs: ① The Rationale for the Three-Stage Staging: Skipping Stage 1 and launching straight into Stage 2 with an uninitialized connector causes severe gradient divergence in the LLM. Skipping Stage 3 leaves the model vulnerable to sycophancy, object existence hallucinations, and repetitive generation loops. ② Data Mixture Ratios in Stage 2: Stage 2 requires a carefully calibrated data recipe: 30% conversational QA, 25% detailed captioning, 20% document/chart OCR, 15% complex multi-step visual math reasoning, and 10% pure text instruction data. Pure text data prevents degradation of coding and math reasoning. ③ Synthetic Data Generation for Stage 3: Hand-labeling preference pairs for multimodal DPO is expensive. Automated pipelines generate negative pairs (yly_l) by prompting frontier models to deliberately introduce factual errors (e.g., swapping colors, adding non-existent objects, modifying chart numerical values) or by selecting rejected completions from early model checkpoints. ④ Compute Budget Allocation: Stage 1 is computationally cheap (only training a 20M parameter MLP for 1 epoch on 600K samples takes <4< 4 hours on 8x A100s). Stage 2 consumes 85-90% of total compute; Stage 3 consumes <10%< 10\% of compute but yields critical gains in human evaluation benchmarks. ⑤ Interview Strategy: Detail the status of components (frozen vs trainable) across all three stages, formulate the loss objectives including MDPO, explain why Stage 1 protects the LLM from random noise, and emphasize the necessity of mixing text-only data into Stage 2.
⚠️ Common Interview Pitfalls
  • ✕
    Omitting text-only instruction datasets during Stage 2 multimodal fine-tuning, triggering severe regression in text reasoning capabilities
  • ✕
    Attempting joint training of the LLM and an uninitialized connector from scratch in a single stage, destabilizing model convergence
  • ✕
    Skipping Stage 3 preference alignment, allowing the model to suffer from high rates of visual hallucination and verbose rambling
🎯 Interviewer Follow-up Inquiries
  • ?
    How does Multimodal Direct Preference Optimization (MDPO) specifically penalize object hallucination in vision-language models?
  • ?
    Why is the compute cost of Stage 1 connector alignment negligible compared to Stage 2 instruction fine-tuning?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

Explore the comprehensive technical article, exam cards, and global architecture tree.

← PreviousM6-031: Impact of Dynamic High Resolution on Optical Character Recognition and Document Understanding📋Back to BankNext →M6-033: Multimodal Benchmark Taxonomy and Dimensional Capability Evaluation in VLMs
中文速览与面试要点

描述 VLM 的典型三阶段训练流程。

① 对齐(只训连接器)→ ② 指令微调(解冻 LLM)→ ③ 可选的对齐/偏好优化(DPO)。

核心要点

  • 数学机理: 三阶段流程 (以 LLaVA 系列为代表)。(1) 阶段一:特征对齐预训练 —— 冻结视觉塔与 LLM ,只训练连接器;数据是 图文对 (图像 + 描述,如 CC3M 的子集),损失是'根据图像生成描述'的交叉熵。 目的 ——让连接器学会把视觉特征'翻译'到 LLM 能理解的空间(对齐)。 数据量 ——通常较小(数十万到数百万图文对,LLaVA 用 595k); 训练步数 少(1 epoch 左右)。(2) 阶段二:多模态指令微调 —— 解冻 LLM (视觉塔通常仍冻结),用 多模态指令数据 (问答、对话、推理、OCR 等)联合训练连接器与 LLM。 目的 ——(a) 让 LLM 学会'按指令使用视觉信息';(b) 提升多样任务能力。 数据 ——质量比数量关键(LLaVA 用 GPT-4 生成的 158k 指令数据;后续工作用更大规模); 格式 —— (图像, 指令, 回答) 三元组。(3) 阶段三:偏好优化(可选但重要) ——用 偏好数据 (对同一图文输入的两个回答做人类/AI 偏好标注)做 DPO/RLHF。 目的 ——(a) 减少 幻觉 (VLM 的主要问题);(b) 提升有用性与格式遵循;(c) 对齐人类偏好。 代表 ——LLaVA-RLHF、RLHF-V(用细粒度偏好数据减少幻觉)。 其他阶段/变体 ——(a) 视觉塔的继续训练 (阶段 2.5)——高分辨率/新领域适配时解冻视觉塔;(b) 多阶段混合 (如 Qwen2-VL 的多阶段:先对齐、再多任务预训练、再指令微调);(c) 持续预训练 (用大规模交错图文数据)。 关键原则 ——' 先对齐、再联合、最后偏好 ';且 每阶段的数据质量与任务覆盖 决定上限。 训练细节 ——(a) 损失掩码 (只对回答算损失,与文本 SFT 一致);(b) 学习率 (连接器阶段较大、LLM 阶段较小);(c) 序列打包 (多模态数据长度差异大,需注意 padding 效率)。
  • 深度剖析与工程权衡:① '先对齐再联合'是关键顺序 ——若一开始联合训练,随机初始化的连接器会产生'无意义视觉 token',破坏 LLM 的语言能力。② '阶段一数据量不必大' ——它的目的是'对齐'而非'学知识';故数十万图文对足够(LLaVA 用 595k)。③ '阶段二数据质量决定上限' ——LLaVA 用 GPT-4 生成指令数据是关键创新(覆盖多样任务、答案质量高);后续工作(如 ShareGPT4V、Allava)进一步扩大与改进。④ '阶段三对 VLM 尤其重要' ——因为 VLM 幻觉 (描述图中不存在的内容)是主要问题;偏好优化(尤其'细粒度偏好',如 RLHF-V 用'逐句标注')能显著减少幻觉。⑤ '视觉塔冻结的取舍' ——冻结省算力但限制'高分辨率/新领域适配';故需按需解冻(见连接器训练策略题)。⑥ 面试要点 ——被问'VLM 怎么训练',应给出' 三阶段(对齐连接器 → 指令微调 → 偏好优化)+ 每阶段的目的与数据 + 为什么顺序重要 ',并强调' 阶段三对减少 VLM 幻觉重要 ';这是 VLM 类问题的基本盘。
  • 阶段一:冻结视觉塔与 LLM,只训连接器(图文对齐)
  • 阶段二:解冻 LLM,用多模态指令数据微调
  • 阶段三:偏好优化(DPO/RLHF)提升有用性与减少幻觉

常见陷阱

  • 跳过阶段一直接联合训练(破坏语言能力)
  • 忽略阶段三(VLM 幻觉严重)