Abstract
Text-based Visual Question Answering (TextVQA) requires models to read and reason about text within a visual scene. While Transformer-based architectures have shown promise, they often lack explicit spatial awareness, relying on fully-connected self-attention that ignores the geometric layout of the image. In this work, we propose the Spatially Aware Multimodal Transformer (SA-M4C). Our model explicitly incorporates spatial relationships between objects and OCR tokens through a spatial relationship graph. By restricting attention heads to specific geometric relations, we provide a strong inductive bias that improves reasoning capabilities. SA-M4C achieves state-of-the-art performance on the TextVQA and ST-VQA benchmarks, with significant gains on questions requiring spatial reasoning.
Introduction
Visual Question Answering (VQA) has evolved significantly, yet TextVQA remains a unique challenge. Answering a question like "What is the expiration date on the medicine bottle to the left of the sink?" requires a model to detect entities, read text, and understand spatial relationships ("to the left of"). Existing models, such as the Multimodal Multi-Copy Mesh (M4C), utilize Transformers with global self-attention. This "look-at-everything" approach forces the model to implicitly learn spatial structures, often leading to redundant features and a failure to capture local context effectively.
Methods
The core of our approach is the Spatially Aware Multimodal Transformer (SA-M4C), which replaces standard self-attention with a mechanism guided by a Spatial Relationship Graph.
The Spatial Relationship Graph
We construct a graph where nodes represent detected objects and OCR (Optical Character Recognition) tokens. Edges in this graph encode 12 distinct spatial relationships: eight directional (North, South, East, West, and diagonals) and four topological (Overlap, In, Contains, and Self). This graph serves as a structured representation of the image's geometric layout.
Spatially Aware Self-Attention
Rather than allowing every node to attend to every other node, we restrict the attention span of each head in the Transformer. Each head is assigned a subset of the 12 spatial relations and only attends to neighbors within those categories. This "sparse" attention mechanism forces heads to specialize—for instance, one head might focus on horizontal relations while another focuses on containment. This specialization reduces redundancy and improves the model's ability to focus on relevant local context.
Implementation Details
We build upon an improved baseline (M4C†), which utilizes a ResNeXt-152 visual backbone and Google OCR. The SA-M4C model integrates the spatially aware layers into this robust framework, ensuring that improvements are due to the architectural innovation rather than better features alone.
Key Results
SA-M4C demonstrates significant improvements across multiple benchmarks:
- TextVQA Accuracy: The model achieved 45.4% accuracy on the validation set, a 2.2% absolute improvement over the M4C† baseline and a 6% increase over the original M4C.
- Spatial Reasoning: On a subset of questions specifically requiring spatial reasoning, accuracy improved by 4.62%.
- ST-VQA: The model set a new state-of-the-art with an ANLS score of 0.504 on the test set.
- Visual Grounding: The model was 8.8% more likely to pick the correct answer directly from the OCR tokens, indicating superior grounding in visual evidence.
Qualitative analysis, including "flip tests" (e.g., changing "left" to "right" in a query), confirms that the model correctly adapts its focus based on spatial cues, whereas baseline models often fail to update their answers.
Conclusion
By introducing an explicit spatial inductive bias, SA-M4C addresses a critical weakness in multimodal Transformers for TextVQA. The use of a spatial relationship graph to guide attention leads to better visual grounding and more accurate reasoning. Future work will focus on improving OCR robustness and incorporating absolute positional cues to further enhance performance.
Summary updated