Capturing Long-range Contextual Dependencies with Memory-enhanced Conditional Random Fields

Fei Liu, Timothy Baldwin, Trevor Cohn

Introduction

Conditional Random Fields (CRFs) have long been a cornerstone of sequence tagging in natural language processing (NLP). However, traditional linear-chain CRFs are inherently limited by their local nature, typically only considering immediate neighbors when making predictions. This "locality bias" makes it difficult to capture long-range dependencies, where the label of a word might depend on context appearing much earlier in a document. For instance, identifying a mention of "Interfax" as an organization is significantly easier if the model can reference a previous mention of "Interfax news agency" from several paragraphs prior.

While Recurrent Neural Networks (RNNs) and LSTMs were designed to handle sequences, they often struggle with long-term memory in practice, favoring recent inputs. The Memory-Enhanced Conditional Random Field (ME-CRF) addresses this by integrating an external memory and attention mechanism directly into the CRF framework, allowing for unrestricted access to the entire sequence context without sacrificing exact mathematical inference.

Methodology: The ME-CRF Architecture

The core innovation of the ME-CRF is the combination of structured sequence prediction with the queryable architecture of Memory Networks. The model processes information through several distinct layers to ensure both global context and local sequence constraints are respected.

The ME-CRF architecture integrates a memory layer with an attention mechanism to inform the final CRF sequence tagging layer.
  1. Memory Layer: The model utilizes bi-directional Gated Recurrent Units (Bi-GRUs) to encode the entire input sequence (such as a full forum thread or news article) into a memory bank. This step preserves the temporal and structural ordering of the text.
  2. Attention Mechanism: At each time step, the model computes an attention score between the current input and every item stored in the memory bank. This allows the model to dynamically "look back" and retrieve relevant information from any point in the sequence.
  3. CRF Layer: The resulting attention-weighted context vector is combined with the current input and fed into a linear-chain CRF. This layer performs the final sequence tagging using the exact Viterbi decoding algorithm, ensuring the most likely sequence of labels is found.
  4. Curriculum Learning: To stabilize training on complex tasks, the authors implemented a curriculum learning strategy where the CRF's transition matrix is frozen for the initial 20 epochs. This encourages the model to first learn to utilize the memory for classification before refining the sequential transition rules.

Experimental Evaluation

The authors evaluated the ME-CRF on two challenging tasks that demand long-range contextual understanding:

  • Forum Thread Discourse Parsing (CNET Dataset): This task involves predicting the "Link" (which previous post a current post is replying to) and the "Dialogue Act" (the nature of that reply). Forum threads are often non-linear and deep, making them ideal for testing long-range dependencies.
  • Named Entity Recognition (CoNLL 2003): A standard benchmark for identifying entities like people, organizations, and locations in news text. Success here often depends on recognizing consistent entity mentions across a whole article.

Key Results and Insights

The ME-CRF demonstrated significant improvements over baseline models. On the CoNLL 2003 NER task, it achieved an F-score of 89.5%, outperforming standard CRFs (86.1%) and Bi-LSTM-CRFs (88.8%) under identical conditions.

In the forum discourse task, the ME-CRF+ (utilizing curriculum learning) achieved a state-of-the-art joint F-score of 71.2%. A critical finding was the model's robustness as the complexity of the task increased. As forum threads grew deeper, the ME-CRF's performance degraded much more gracefully than traditional dependency-parser-based approaches.

Performance comparison across different post depths in forum threads, showing ME-CRF+ maintaining higher F-scores as threads become more complex.

Beyond raw metrics, the ME-CRF introduces the concept of "soft label consistency." Unlike previous models that used hard constraints to force identical tags on repeated words, the ME-CRF learns to use attention to naturally inform its decisions based on previous context. This flexibility allows it to overcome the locality bias inherent in standard RNN architectures.

Conclusion

By augmenting the classic CRF with a queryable memory layer, the ME-CRF provides a powerful solution for sequence tagging tasks where long-range context is vital. While the current implementation uses a single "memory hop," the architecture is modular and can be extended with multiple hops for tasks requiring more complex reasoning. This work bridges the gap between efficient structured prediction and the expansive contextual reach of modern memory-based neural networks.

Summary updated

BibTeX
@inproceedings{liu2017capturing,
  author = {Fei Liu and Timothy Baldwin and Trevor Cohn},
  title = {{Capturing Long-range Contextual Dependencies with Memory-enhanced Conditional Random Fields}},
  booktitle = {IJCNLP},
  year = {2017},
}
Figure