ContextQFormer: A New Context Modeling Method for Multi-Turn Multi-Modal Conversations

Yiming Lei, Zhizheng Yang, Zeming Liu, Haitao Leng, Shaoguo Liu, Tingting Gao, Qingjie Liu, Yunhong WangarXiv 2025 · DOI

Introduction

Multi-modal Large Language Models (MLLMs) such as GPT-4 and MiniGPT-4 have demonstrated remarkable capabilities in understanding and describing individual images. However, these models often encounter significant hurdles when tasked with extended, multi-turn conversations. Two primary challenges hinder current open-source MLLMs: Contextual Fading, where models lose track of earlier dialogue turns as the conversation length increases, and Data Scarcity, specifically the lack of large-scale datasets designed for complex, multi-image, and multi-turn interactions.

To address these issues, this research introduces ContextQFormer, a novel memory-based architecture, alongside TMDialog, a massive new dataset specifically curated for multi-turn multi-modal instruction tuning.

The ContextQFormer Architecture

The core innovation of this work is the ContextQFormer module, which functions as a dedicated memory bank for the MLLM. Unlike standard models that may become overwhelmed by "historical noise"—irrelevant or outdated information from previous turns—ContextQFormer selectively reactivates relevant past information.

Feature Extraction and Memory Queue

For every turn in a conversation, the model extracts high-level "summary" representations. It uses a Vision Transformer (ViT) for images and RoBERTa for text, specifically focusing on the [CLS] tokens. These summary tokens are stored in a chronological memory queue. By using high-level embeddings as "memory units" rather than raw tokens, the model maintains a cleaner signal for long-term context, which is computationally more efficient.

Cross-Attention Mechanism

When the model receives a new instruction, it utilizes learnable queries to perform cross-attention over the historical memory queue. This mechanism allows the model to "pull" relevant details from the history that are pertinent to the current query, effectively mitigating the forgetting problem common in long-context scenarios.

The TMDialog Dataset

To train and evaluate ContextQFormer, the researchers developed TMDialog, a large-scale dataset containing over 1.5 million samples. The dataset is categorized into five distinct interaction types: Continuous Question, Interaction, Long Memory, Multi Images, and Long Conversations.

The TMDialog data construction pipeline utilizing GPT-4 for generation and GPT-3.5 for factual verification.

As illustrated in the construction pipeline, the authors employed a sophisticated synthetic data generation strategy. GPT-4 generated dialogues based on detailed image descriptions and demonstration examples. To ensure high data quality and minimize hallucinations, a "recheck" phase using GPT-3.5-turbo was implemented to filter out factually incorrect responses. This results in a dataset that is more logically consistent and features longer conversations than existing benchmarks like VisualDialogue or ImageChat.

Experimental Results

The researchers compared ContextQFormer against leading baselines, including mPLUG-owl and VisualGLM. The evaluation focused on a practical metric called the Available Rate—the percentage of responses that are both rational and free from hallucinations.

A comparison of model performance in multi-turn dialogue, demonstrating ContextQFormer's ability to avoid hallucinations compared to VisualGLM and mPLUG-owl.

Key findings from the experiments include:

  • Superior Reliability: ContextQFormer achieved an available rate of 68.17%, outperforming mPLUG-owl (66.40%) and a standard LoRA-only baseline (64.01%).
  • Enhanced Rationality: The model reached a rationality score of 0.9015, indicating its responses were significantly more coherent within the flow of a long conversation.
  • Multi-Image Proficiency: ContextQFormer showed marked improvements in "Multi Images" scenarios, where baseline models frequently failed to distinguish between different visual inputs provided in the same thread.

Conclusion and Future Work

ContextQFormer represents a significant step forward in modeling long-range dependencies for multi-modal dialogue. By combining a dedicated memory module with the high-quality TMDialog dataset, the researchers have notably reduced hallucinations and improved conversational rationality.

Future research directions include scaling the architecture to larger models (e.g., 13B or 70B parameters) and implementing "dynamic activation" to further optimize computational overhead. Additionally, the team aims to incorporate more natural human dialogues to further ground the model in real-world conversational nuances.

Summary updated

BibTeX
@misc{lei2025contextqformer,
  author = {Yiming Lei and Zhizheng Yang and Zeming Liu and Haitao Leng and Shaoguo Liu and Tingting Gao and Qingjie Liu and Yunhong Wang},
  title = {{ContextQFormer: A New Context Modeling Method for Multi-Turn Multi-Modal Conversations}},
  year = {2025},
  eprint = {2505.23121},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.23121},
}
Figure