FltLM: An Intergrated Long-Context Large Language Model for Effective Context Filtering and Understanding

Jingyang Deng, Zhengyang Shen, Boyang Wang, Lixin Su, Suqi Cheng, Ying Nie, Junfeng Wang, Dawei Yin, Jinwen Ma · OpenReview

Abstract

The development of Long-Context Large Language Models (LLMs) has markedly advanced natural language processing by facilitating the process of textual data across long documents and multiple corpora. However, Long-Context LLMs still face two critical challenges: The lost in the middle phenomenon, where crucial middle-context information is likely to be missed, and the distraction issue that the models lose focus due to overly extended contexts. To address these challenges, we propose the Context Filtering Language Model (FltLM), a novel integrated Long-Context LLM which enhances the ability of the model on multi-document question-answering (QA) tasks. Specifically, FltLM innovatively incorporates a context filter with a soft mask mechanism, identifying and dynamically excluding irrelevant content to concentrate on pertinent information for better comprehension and reasoning. Our approach not only mitigates these two challenges, but also enables the model to operate conveniently in a single forward pass. Experimental results demonstrate that FltLM significantly outperforms supervised fine-tuning and retrieval-based methods in complex QA scenarios, suggesting a promising solution for more accurate and reliable long-context natural language understanding applications.

Introduction

As Large Language Models (LLMs) evolve to process tens of thousands of tokens, they encounter significant hurdles in maintaining comprehension accuracy. Two primary issues persist: Lost in the Middle, where models struggle to retrieve information buried in the center of a prompt, and the Distraction Issue, where the attention mechanism's focus is dispersed across irrelevant "noise" documents. Traditional retrieval-augmented systems attempt to solve this by pre-filtering documents, but they often fail if the retriever's precision is low, still overwhelming the LLM with distractors. FltLM addresses these challenges by integrating filtering and reasoning within a single architecture.

Methodology

FltLM is built upon a 2N-layer Long-Context LLM (utilizing a ChatGLM3-6B base). The architecture is bifurcated into two functional stages:

  1. The Context Filter (First N layers): The model employs a strategy of appending a special token (</doc_i>) to every document. The hidden states of these tokens are used to compute relevance scores for each document in the context.
  2. The Soft Mask Mechanism (Remaining N layers): Based on the relevance scores, FltLM applies a learnable soft mask to the attention matrix in the subsequent layers. Unlike a "hard" filter that deletes tokens, the soft mask dynamically reduces the influence of irrelevant information, allowing the model to remain end-to-end trainable and robust to filter uncertainty.
FltLM architecture and soft mask mechanism. The left panel illustrates the dual-layer structure with integrated filtering, while the right panel shows the resulting attention matrix where irrelevant documents are suppressed.

The model is optimized via a joint loss function: $L = L_{lm} + \lambda L_{flt}$. The filter loss ($L_{flt}$) is a modified InfoNCE loss that incorporates an absolute threshold and margin, ensuring the model can distinguish relevant content regardless of the total document count.

Experimental Evaluation

The authors trained FltLM on approximately 85,000 samples derived from multi-hop QA datasets (HotpotQA, 2WikiMultiHopQA, and MuSiQue), simulating a 32k-token context by replacing snippets with full Wikipedia articles. Evaluation was conducted using the LongBench English multi-document QA datasets (HQA, 2WIKI, and MSQ).

Key Results and Insights

FltLM achieved an average F1 score of 67.58% on LongBench tasks, outperforming standard Supervised Fine-Tuning (65.24%) and traditional retrieval pipelines.

Superior Retrieval Performance: When evaluated as a retriever, FltLM's internal filter outperformed dedicated state-of-the-art models such as BGE-m3 and E5-Mistral, achieving higher recall with fewer documents.

Recall performance of FltLM compared to baseline retrieval models across HQA, 2WIKI, and MSQ datasets. FltLM (ours) reaches peak recall significantly faster.

Reciprocal Enhancement: A key finding was that the QA and filtering tasks mutually benefit each other. Training with the combined loss made the context filter more accurate than training it in isolation, as feedback from the reasoning task helps the filter learn better semantic features.

Robustness to Positioning: By scoring every document independently, FltLM effectively solves the "Lost in the Middle" problem. Performance remained stable even when relevant documents were moved to the center of the prompt, unlike traditional fine-tuned models.

Conclusion

FltLM offers a streamlined, "one-stop-shop" solution for long-context processing by integrating filtering directly into the forward pass. While currently focused on multi-hop QA, future work will explore its generalization to other long-form tasks and its scalability to even larger context windows using more efficient attention mechanisms.

Summary updated

BibTeX
@inproceedings{deng2024fltlm,
  author = {Jingyang Deng and Zhengyang Shen and Boyang Wang and Lixin Su and Suqi Cheng and Ying Nie and Junfeng Wang and Dawei Yin and Jinwen Ma},
  title = {{FltLM: An Intergrated Long-Context Large Language Model for Effective Context Filtering and Understanding}},
  booktitle = {ECAI},
  year = {2024},
  url = {https://openreview.net/forum?id=CbGQrkwap5},
}
Figure