Skip to content

Image-language and multimodal models · Image-language and multimodal models · MM006 · Model

LXMERT

Learns within-modality and cross-modality relationships through multiple pretraining tasks. It explicitly separates a language encoder, an object-relationship encoder and a cross-modal encoder, making its task mixture…

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Learns within-modality and cross-modality relationships through multiple pretraining tasks. It explicitly separates a language encoder, an object-relationship encoder and a cross-modal encoder, making its task mixture central to the model definition.

Question / objective

Can jointly learning words, objects, matching and question answering improve grounded visual-language reasoning? The learning target replaces a null/alternative hypothesis formulation; benchmark evaluation is a separate statistical task.

Method type and supervision

Model/system family. Image-language or broader multimodal learning using the paired, generated or task-specific supervision described below. This is not a classical significance test.

Architecture / computational structure

Three encoder components process language, object relations and cross-modal exchange. Masked language, object-feature regression, object-label prediction, matching and question answering supply distinct pretraining signals.

Assumptions

Question-answer and object-label tasks use explicit supervision. Detector errors and answer priors can distort alignment; calling the whole recipe unsupervised would be inaccurate. Dataset overlap between pretraining and downstream tasks must be checked.

Formula / computational definition

L=λMLMLMLM+λfLfeature+λoLobject+λmLmatch+λqLQAL=\lambda_{MLM}L_{MLM}+\lambda_fL_{feature}+\lambda_oL_{object}+\lambda_mL_{match}+\lambda_qL_{QA} summarizes the task mixture. Each coefficient weights a separately defined loss, not a new hypothesis test. This captures the central mechanism; consult the primary source for all masks, stages, normalizations and loss terms.

Parameters and notation

Learned/estimated quantities: Encoder, cross-attention, predictor and task-head weights are learned. Task labels and detector features are supplied supervision; task weights and sampling proportions are chosen. Hyperparameters and design choices: Number of regions, encoder depths, task mixture, masking probabilities and label vocabularies change transfer and compute.

Fitting, fine-tuning, and adaptation

Fit a downstream head and cross-modal layers before fully unfreezing. Preserve several task metrics during adaptation to avoid optimizing answer priors at the expense of grounding. Adapter tuning is a custom option that must be validated. Save the exact trainable-module selection, data split, loss, optimizer and processor configuration; distinguish parameter adaptation from inference-time prompt tuning.

How to use and calibrate

Choose a specific model/processor and task protocol, validate preprocessing on known examples, tune only on a held-out development set and freeze the final evaluation. Report visual question-answering scores plus language-only controls, rare-answer performance and region-occlusion stress tests.

Example application

Answer object-attribute or relationship questions in a visual reasoning dataset.

Interpretation / pitfalls

Watch out

Reported capability is conditional on available visual evidence, data coverage and the chosen task. Report visual question-answering scores plus language-only controls, rare-answer performance and region-occlusion stress tests. A successful numeric component example is not evidence that a complete system achieves a published benchmark score.

Python and R code examples

Component: Keep distinct pretraining losses separately visible. Dependencies: shared NumPy/base-R setup above. Python: executed successfully. R: unexecuted. Complete model training/inference: not run.

Full implementation routes: Python: use the authors’ multi-encoder implementation and specified pretraining/task heads; R: audit task losses and evaluation natively, bridging the full learned model and detector.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — Keep distinct pretraining losses separately visible.

Shared setup for this chapter
import numpy as np
def softmax(x):
    z = np.asarray(x, dtype=float)
    e = np.exp(z-z.max())
    return e/e.sum()
losses=np.array([1.2,.3,.8,.4,1.0])
weights=np.array([1.,.5,1.,1.,.8])
print(dict(zip(["MLM","feature","object","match","QA"],losses)))
print("illustrative combined loss",weights@losses)
R

Component demo, not a trained model — Keep distinct pretraining losses separately visible.

losses <- c(MLM=1.2,feature=.3,object=.8,match=.4,QA=1)
weights <- c(1,.5,1,1,.8)
print(losses); print(sum(weights*losses))

Sources

From the CodeSplash reference, entry MM006.