research33 min studyLesson 797 in Engineering

A multimodal conversation is an ordered media-and-token contract

Preserve roles, media identity, feature expansion, training labels, and padding through the exact checkpoint-compatible processor and template.

On this page

What you’ll understand

  • Match ordered media references with their processed payloads.
  • Distinguish visible sentinels from expanded visual positions.
  • Test prompt, feature, label, and batch alignment under a pinned serialization contract.

A prompt that looks readable can still attach the first image's features to the second image's question or omit the assistant boundary expected by a checkpoint. Multimodal serialization coordinates role structure, typed content, media references, processor outputs, and model-specific feature insertion. It also determines which tokens are training targets and which positions are padding. Treat the rendered string as one intermediate artifact, not the whole input. Correctness requires tracing the ordered media and token representation all the way to the model's merge boundary.

Use the checkpoint's actual structured input format

Versioned Transformers 4.57.1 multimodal chat documentation describes message content as a list of typed blocks rather than the plain content string used by its text-only examples. Its processor can combine preprocessing, tokenization, and chat templating. This is a documented API family, not a universal format for every model service. A specific checkpoint can have different supported roles, separators, media markers, or image-count behavior. Preserve the actual template and processor artifacts with the model, and verify their outputs instead of hand-building a plausible-looking prompt from an unrelated example.

Assign stable identities to media and retain their order through loading, decoding, preprocessing, and feature expansion. If asynchronous fetching completes in another order, restore the declared conversation mapping before merging features. Repeated references and shared cached payloads need explicit ownership semantics. Count and validate media using the selected contract rather than relying on total tensor size. The LLaVA documentation for this pinned version also warns that technical multi-image input support does not establish that a checkpoint was trained to handle several images well; interface acceptance and task capability remain separate questions.

orderedMediaIDs⁡(conversation)=orderedMediaIDs⁡(merge inputs)\operatorname{orderedMediaIDs}(\text{conversation})=\operatorname{orderedMediaIDs}(\text{merge inputs})
This is a required invariant for the chosen ordered-media merge contract, including repeated references where supported. IDs describe logical ownership, not necessarily one physical tensor per reference. Shape equality and equal counts alone do not establish this ordered identity relation or semantic multi-image capability.↔ Scroll wide equations horizontally.

Expansion and training labels must follow the same sequence

A rendered image sentinel may expand into many model positions, while other architectures keep visual memory separate. For a concatenated interface, compare the processor's expected inserted positions with the connector's retained feature counts. Truncation, an incompatible feature-selection rule, or a missing payload can break this relation. Do not repair it by silently repeating or dropping arbitrary features. Reject or apply a documented supported fallback before the model consumes a prompt with a different media meaning than the user supplied.

During autoregressive instruction training, the loss mask must match the intended target tokens and role boundaries. Original LLaVA training illustrates supervising assistant responses under its particular conversation format; another objective may supervise a different set. Padding masks and target-ignore conventions are separate from causal and media-ownership masks. Test the final token IDs, labels, attention mask, feature lengths, and association together. A batch with valid individual examples can still fail if left/right padding or token offsets shift the merge or target positions differently.

Lvalid=Ltext+Lformat+∑m=1MVmL_{\rm valid}=L_{\rm text}+L_{\rm format}+\sum_{m=1}^{M}V_m
This count applies only to a specified concatenated-feature interface. V_m counts the retained feature slots inserted for media reference m; text and formatting are disjoint counted categories. A visible sentinel count is not generally the sum of V_m, and separate cross-attention architectures need their actual different accounting.↔ Scroll wide equations horizontally.

Create a serialized fixture that exposes swapped evidence

Use two deliberately distinguishable media objects and questions that require knowing which one is referenced. Test single examples, batched examples with different lengths, missing files, repeated references, history truncation, and round-trip inspection of the rendered prompt. Save expected identities and compatible shapes as a fixture for the chosen library and checkpoint revision. Test generation start and stop boundaries independently from training labels. A fluent answer is a weak serialization check because the language model can produce one even when it ignored or misattached the evidence.

The modular lab shows a known ordered sequence, not a conversation parser. Reset, set both m=10 and additive a=3, predict residues three and six after one and two Steps, then inspect. Reset and set both m=10 and a=5 for a period-two orbit returning to zero after two Steps. Each Step advances one addition per 0.5 seconds. Its finite recurring labels carry no media, roles, tokenizer, template, feature expansion, or target mask. It only illustrates why a declared order must be followed and why a small recurring number is not a complete identity contract.

Two sentinels can represent sixty-four feature positions

A hypothetical processor contract supports ordered images A then B and retains 32 feature slots per image. Text occupies 80 positions and formatting 12, excluding visual insertion. This toy is not a claim about LLaVA's image-feature count or multi-image training.

  1. The conversation references[A,B], so the merge must receive features in that ownership order. A fetch that completes B before A must restore[A,B]; two payloads of matching shapes do not justify swapping them.

  2. Two visible image markers correspond to 32+32=64 feature positions under this contract. Valid input length is 80+12+64=156, not merely the text length plus two ordinary positions.

  3. If B fails to load, the connector supplies only 32 visual positions against the expected 64. The request must follow its declared failure or supported fallback path rather than silently presenting A's features twice or pretending B was inspected.

The result

The processor's exact ordered feature contract determines valid input. Matching counts, media ownership, and task capability must all be checked separately.

Explore the model

Interactive lab

Interactive lab · modular

A sequence rule is inspectable but contains no media parser

Reset, set both m=10 and a=3, predict residues 3 and 6 after one and two Steps, then inspect. Reset and re-enter both m=10 and a=5 for period 2 and return to zero after two Steps. The orbit n×a mod m starts at zero and advances one addition per 0.5-second Step. It has no role format, tokenizer, payload, visual features, labels, or identity guarantee.

A sequence rule is inspectable but contains no media parserAddition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Current readings: Residue r0: 0; Orbit period · m/gcd(m,a): 12; Distinct residues visited: 1 of 12. All parameters are adjustable with the labeled controls below.Repeated addition modulo 12: the current residue is 0, and the orbit period is 12.01234567891011+ 5mod 12An additive orbitn = 0rₙ = 0Period = 12Cycle starts at 0:0 → 5 → 10 → 3 →8 → 1 → 6 → 11 →4 → 9 → 2 → 7 → 0Exact residues · two additions per second
Additive orbitCurrent residue / next edge
Residue r0
0
Orbit period · m/gcd(m,a)
12
Distinct residues visited
1 of 12
t = 0 s

Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forPreserve actual ordered media identity and model-specific expansion through the real processor.

Check your understanding

Two image feature tensors have identical shapes but arrive in the opposite order from their conversation references. What establishes a correct merge?

Try it yourself

A declared one-image prefix has 48 visual slots,90 text positions,10 formatting positions, and 64 reserved generated positions. Its limit is 256. Calculate valid input length, total reservation, and remaining room. Does that arithmetic validate the conversation template?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Add the disjoint categories, then distinguish a length invariant from role and ownership correctness.

Compare with the solution

Valid input length is 48+90+10=148; total reservation is 148+64=212, leaving 44. These counts can pass while the role markers, target mask, or media ownership remain wrong. Validate the compatible template and final processor outputs separately.

Take it with you

  • Serialize roles and typed media with the exact checkpoint-compatible processor and template.
  • Sentinels, retained features, valid positions, and training labels require consistent but distinct accounting.
  • Use distinguishable-media fixtures to expose swaps and unsupported fallback behavior.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.