Masked Cross-Entropy (Masked CE) is the standard VLM training loss — sequence-level next-token prediction that computes loss only on assistant (model-answer) text tokens, masking gradients of user-instruction tokens and all vision patch tokens:
L=−t∈assistant∑logpθ(yt∣x<t)
The input is
x=[v1,…,vN,u1,…,um,a1,…,aL] (vision patches → user instruction → assistant answer); causal attention sees all tokens, but only
t∈assistant positions contribute loss — exactly the LLM SFT labels mechanism where non-supervised positions are set to
ignore_index (e.g. -100).
Why mask: (1) vision patch tokens have no "next token" supervision target (they come from the frozen encoder, they are not generation targets) — CE on them forces patch-sequence prediction, pointless and harmful to text learning; (2) user instructions are not content the model should generate — predicting them teaches the model to parrot the user; (3) compute efficiency — with high-resolution inputs, vision tokens dominate the sequence (336×336, patch 14 → 576 vision tokens, often 85–90% of the sequence), so masking cuts backward-computation roughly an order of magnitude. An optional
1/L normalizes by supervised-token count.