Interpretable Language Modeling via Induction-head Ngram Models

Eunji Kim, Sriya Mantena, Weiwei Yang, Chandan Singh, Sungroh Yoon, Jianfeng Gao · OpenReview

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities across diverse domains. However, their "black-box" nature remains a significant hurdle for deployment in high-stakes environments like medicine or neuroscience, where interpretability is paramount. While traditional n-gram models offer full transparency, they are often too brittle to handle the nuances of natural language, such as rephrasings or minor variations.

To bridge this gap, we introduce Induction-head ngram models (Induction-Gram), also referred to as the Generalized Induction-Head Model (GIM). This approach combines the grounding of n-gram models with the flexibility of neural similarity, creating an efficient and interpretable framework for next-token prediction.

Methodology: The Induction-Gram Framework

Induction-Gram functions as a retrieval-based model that predicts the next token by searching the immediate input context for patterns. It mimics the "induction head" behavior observed in Transformers—mechanisms that identify and complete repeated sequences.

The model employs a dual-matching strategy:

  1. Exact Matching: Utilizing the Infini-gram framework, the model searches for identical token sequences within the context or a massive reference corpus.
  2. Fuzzy Matching: To handle linguistic variations, a lightweight Fuzzy Matching Model is employed. This small transformer (typically 3-4 layers) is trained via knowledge distillation from a large teacher LLM (e.g., LLaMA-2).
Distillation process and fuzzy matching mechanism in Induction-Gram.

Instead of generating tokens, this distilled model produces feature embeddings used to calculate similarity between sequences based on Jensen-Shannon Divergence (JSD). By scoring the similarity between the current sequence and previous segments in the context, Induction-Gram identifies the most likely next token while providing explicit grounding for its prediction.

Performance and Scaling

Induction-Gram was evaluated on various datasets, including BabyLM, OpenWebText, and The Pile. A key finding is the relationship between "Effective n" (the length of the matching sequence) and prediction accuracy.

Next-token accuracy and match length distribution.

As shown in Figure 3, next-token accuracy significantly improves as the length of the matching sequence increases. Induction-Gram improves accuracy by up to 26 percentage points over baseline interpretable models like Infini-gram. Furthermore, the model's efficiency allows it to serve as a "draft model" for speculative decoding, achieving up to a 2.27x speedup for LLaMA2-70B.

Natural Language Neuroscience

The interpretability of Induction-Gram makes it uniquely suited for scientific investigation. In a neuroscience setting, the model was tasked with predicting fMRI responses in human participants listening to narrative podcasts. Induction-Gram achieved a 20% relative increase in the correlation of predicted fMRI responses compared to previous interpretable baselines. In specific brain regions associated with language processing, such as the Occipital Face Area (OFA), it reached performance parity with black-box models like LLaMA-2, suggesting that these regions may employ similar pattern-matching mechanisms.

Conclusion

Induction-Gram demonstrates that neural components can be used to enhance interpretable models without sacrificing transparency. By using a neural network for scoring similarity rather than generation, the model remains human-auditable. While it currently lacks the extensive world knowledge of massive LLMs, it provides a powerful tool for high-stakes applications and the scientific study of language processing in the brain.

Summary updated

Abstract

Recent large language models (LLMs) have excelled across a wide range of tasks, but their use in high-stakes and compute-limited settings has intensified the demand for interpretability and efficiency. We address this need by proposing Induction-head ngram models (Induction-Gram), a method that builds an efficient, interpretable LM by bolstering modern ngram models with a hand-engineered "induction head". This induction head uses a custom neural similarity metric to efficiently search the model's input context for potential next-word completions. This process enables Induction-Gram to provide ngram-level grounding for each generated token. Moreover, experiments show that this simple method significantly improves next-word prediction over baseline interpretable models (up to 26%p) and can be used to speed up LLM inference for large models through speculative decoding. We further study Induction-Gram in a natural-language neuroscience setting, where the goal is to predict the next fMRI response in a sequence. It again provides a significant improvement over interpretable models (20% relative increase in the correlation of predicted fMRI responses), potentially enabling deeper scientific investigation of language selectivity in the brain. The code is available at https://github.com/ejkim47/induction-gram.
BibTeX
@misc{kim2024interpretable,
  author = {Eunji Kim and Sriya Mantena and Weiwei Yang and Chandan Singh and Sungroh Yoon and Jianfeng Gao},
  title = {{Interpretable Language Modeling via Induction-head Ngram Models}},
  year = {2024},
  eprint = {2411.00066},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.00066},
}
Figure