TL;DR
Code-MIE reframes Multimodal Information Extraction (MIE) as a unified code generation task rather than relying on traditional natural language templates. By structuring inputs as a single, task-agnostic Python function—enriched with explicit scene graphs and entity attributes—and outputs as structured Python dictionaries, the framework significantly reduces large language model (LLM) hallucinations and achieves state-of-the-art performance across multiple multimodal benchmarks.
What Problem Does This Paper Address?
Information Extraction (IE) tasks—like identifying named entities, tracing coreference chains, and mapping relations—are inherently structured. However, most current Multimodal Information Extraction (MIE) methods force Large Language Models (LLMs) to process these tasks using natural language prompts. This mismatch often leads to formatting errors, structural confusion, and severe model hallucinations because natural language lacks strict syntactic constraints.
While text-only IE has recently experimented with "code-style" prompting (asking the model to write code to express relationships), these methods have been task-specific, requiring engineers to design separate templates for every single sub-task. Furthermore, they haven't been extended to handle multimodal inputs like images or videos. Code-MIE bridges this gap by introducing a unified, task-agnostic code-style framework designed specifically for multimodal data.
Methods
The core innovation of Code-MIE is treating information extraction as a code-completion problem. Instead of prompting an LLM with "Extract the entities from this text," the framework defines a Python function where the inputs are parameters and the outputs are structured dictionaries.
The pipeline consists of three main phases:
- Knowledge Enhancement (Preprocessing):
- Entity Attributes: The raw text is processed by an LLM (
Qwen3-Max) to extract background attributes for potential entities (e.g., a person's occupation or gender; an organization's domain). This provides deep contextual grounding. - Scene Graphs: Images are converted into explicit structural triples (subject, object, relation) using a vision-language model (
Qwen3-VL-235B) to capture clear visual relationships (e.g.,["man", "piano", "play"]). - Template Construction: The framework packages the raw text, extracted entity attributes, and scene graphs into the parameters of a Python function definition (
def information_extraction(...)). The model is then expected to fill out empty target dictionaries (entity_dic,relation_dic, etc.) as its output. - Multimodal Fusion & Fine-Tuning: Implicit visual features are extracted using a Vision Transformer (ViT), projected to match the text embedding dimensions, and concatenated directly with the tokenized code template. The backbone LLM (
Qwen3-8B) is then fine-tuned using Low-Rank Adaptation (LoRA).
Datasets
The authors evaluated Code-MIE on four prominent benchmarks:
- $\text{M}^3\text{D}$: A challenging video-based, multilingual (English and Chinese), and multitasking dataset covering entity recognition, entity chain extraction, relation extraction, and visual grounding.
- Twitter-15 & Twitter-17: Standard image-bound social media datasets used for Multimodal Named Entity Recognition (MNER).
- MNRE: A multimodal relation extraction dataset consisting of text-image pairs crawled from Twitter.
Key Insights and Ideas
- Code as a Regularizer: Code structure acts as a powerful constraint on LLM decoding. Because Python dictionaries and lists have rigid grammatical rules, forcing the model to output code drastically cuts down on conversational filler, extraneous modifiers, and formatting slips.
- Task-Agnostic Synergy: Rather than isolating tasks, a single unified function allows the model to exploit inter-task dependencies. For example, resolving an entity chain sequentially improves the model's downstream ability to identify relations between those chains.
- Dual-Layer Visual Representation: Combining explicit visual knowledge (scene graphs) with implicit visual knowledge (ViT embeddings) yields better reasoning than relying on raw visual features alone. The scene graph acts as a textual bridge that aligns cleanly with the code-style prompt.
Key Results
Code-MIE achieved state-of-the-art (SOTA) results across all evaluated datasets, outperforming both natural language baselines and task-specific code-style models:
- $\text{M}^3\text{D}$ Benchmark: Achieved an average $F1$ score of 61.03% on the English dataset and 60.49% on the Chinese dataset, outperforming the closest baseline by roughly 3%.
- Twitter & MNRE Benchmarks: Posted $F1$ scores of 76.04% (Twitter-15), 88.07% (Twitter-17), and 73.94% (MNRE), showing consistent improvements over text-only code models adapted for vision.
- Hallucination Reduction: Quantitative analysis showed that Code-MIE dramatically lowered hallucination rates compared to natural language templates, particularly on complex multitasking workloads.
Limitations and Future Work
Despite the performance gains, the authors' error analysis highlights a persistent bottleneck: boundary recognition. For both text entity extraction and visual grounding (bounding box localization), the model frequently gets the classification right but struggles to identify the exact boundaries of the span or object.
Additionally, relation extraction remains a difficult task that demands deep reasoning; the model still occasionally predicts false relations between valid entity chains. Future work will likely target finer alignment mechanisms to improve boundary precision and explore scaling the framework to even more complex reasoning chains.
Summary updated