Interpretable Language Modeling via Induction-head Ngram Models

Eunji Kim, Sriya Mantena, Weiwei Yang, Chandan Singh, Sungroh Yoon, Jianfeng Gao · Submission to ICLR 2025 · Rejected

TL;DR

Large language models (LLMs) achieve high predictive accuracy at the cost of interpretability and computational efficiency. Induction-Gram bridges modern scalable $n$-gram models with mechanistic ideas from transformers by incorporating a hand-engineered, neural-assisted "induction head" that performs exact and fuzzy in-context matching. This hybrid model drastically closes the next-token accuracy gap with neural LLMs (up to +26%p), delivers over $2\times$ speedups when serving as a draft model in speculative decoding, and yields a 20% performance boost in voxelwise fMRI brain response prediction.

What Problem Does This Paper Address?

Standard $n$-gram models are fast, fully traceable, and completely interpretable: every probability estimate can be directly audited back to exact occurrences in a training corpus. However, their predictive performance trails modern neural LLMs dramatically. Even state-of-the-art unbounded $n$-gram engines like Infini-Gram suffer from two critical weaknesses:

  1. Distribution shift & context blindness: They rely on global reference corpora and struggle to adapt dynamically to local context or new writing styles.
  2. Brittle exact matching: Minor phrasing differences, typos, or paraphrasing cause exact match lengths (effective $n$) to collapse, ruining predictions.

Induction-Gram tackles these issues by engineering an interpretable LM that borrows one of the transformer’s core mechanisms for in-context learning: the induction head.

Methods

Induction-Gram integrates corpus-level $n$-gram statistics with local context retrieval:

  • Mechanistic Induction Heads via Context Search: In transformers, induction heads detect recurring patterns (e.g., $[A][B] \dots [A] \rightarrow [B]$) to copy completions from prior context. Induction-Gram replicates this behavior by treating recent context as a search index for next-token candidates.
  • Fuzzy In-Context Matching: Exact string matching within short prompts is frequently too brittle. The authors train a lightweight Fuzzy Matching Model (a 3-to-4 layer transformer distilled from LLaMA2-7B) to compute text similarity based on whether two sequences share similar predicted next-token distributions (using Jensen–Shannon divergence).
  • Dynamic Routing: For any given prefix, Induction-Gram evaluates the effective match length $n$:
  • If the match length in the reference corpus ($n_\infty$) or local context ($n_x$) exceeds a tuned threshold $\tau$ (set to 8 or 9), it executes exact matching (prioritizing local context when tied).
  • If matches are shorter than $\tau$, it falls back to fuzzy matching over the context window, using similarity scores as soft token counts.
  • Speculative Decoding & fMRI Encodings: The fuzzy induction module is deployed as a fast draft model for speculative decoding. In natural language neuroscience, the same matching principle is adapted to map story contexts to time-lagged blood-oxygen-level-dependent (BOLD) fMRI brain responses.

Datasets

  • Language Modeling Benchmarks: Evaluated across BabyLM (10M/100M tokens), OpenWebText (~9–10B tokens), The Pile (Pile-val and 383B-token Pile-train), and FineWeb (sample-10BT).
  • fMRI Dataset: Public natural language fMRI dataset from LeBel et al. (2022) / Tang et al. (2023), consisting of 20+ hours of podcast listening data (evaluated on high-quality subject UTS03 across 95,556 voxels).

Key Insights and Ideas

  • Local context often beats massive pretraining: An exact $n$-gram search within the immediate 1024-token prompt alone outperformed a 10B-token reference corpus (OpenWebText) by 5.5%p to 20%p on out-of-domain test sets. Local context closely matches the prompt's underlying distribution.
  • Fuzzy matching rescues low-$n$ regimes: The vast majority of context matches have low effective $n$ ($n < 3$). Distilling next-token similarity distributions into soft matching counts provides massive gains right where standard $n$-gram models fail.
  • Interpretable speculative decoding: Using fuzzy induction heads as a draft model speeds up large models while ensuring that accepted speculative tokens have explicit, human-auditable justifications in the input prompt.
  • Tracing language comprehension in the brain: In fMRI encoding models, induction matching identified that local context tracking is concentrated in specific cortical hubs (e.g., Occipital Face Area and Intraparietal Sulcus), especially during emotionally and narratively critical narrative turns.

Key Results

  • Next-Token Accuracy: Induction-Gram improves next-token prediction accuracy by up to 26%p over Infini-Gram. On BabyLM-test using OpenWebText as a reference, Induction-Gram achieves 43.2% vs. Infini-Gram’s 20.1% (LLaMA-2 tokenizer). On Pile-train, it achieves 49.4%, approaching full LLMs while remaining inspectable.
  • Speculative Decoding Speed: When paired with LLaMA2-70B, Induction-only (fuzzy) delivers over $2.1\times$ to $2.27\times$ speedups, outperforming neural draft models like TinyLLaMA-1.1B while running substantially faster per step.
  • fMRI Brain Prediction: Induction matching achieves a test correlation of 0.087 across all voxels (a 20% relative improvement over the standard interpretable Eng1000 baseline at 0.072). For the top 10% most predictable voxels, it reaches 0.265, virtually matching black-box LLaMA2-70B embeddings (0.268).

Limitations and Future Work

  • Context Dependency: Induction-Gram relies heavily on repetitive or structured context; its induction heads offer little advantage on very short or uninformative prompts.
  • Shallow Reasoning: Because it relies on $n$-gram lookups, Induction-Gram lacks multi-step compositional reasoning and still trails state-of-the-art neural LLMs on complex tasks.
  • Noise Sensitivity in fMRI: While exact induction matching succeeded in fMRI, fuzzy matching failed to beat exact matching due to high noise and temporal smoothing in BOLD signals.
  • Future Directions: Incorporating other mechanistically discovered transformer circuits (e.g., indirect object identification, retrieval heads, numerical circuits) into explicit, hand-engineered symbolic or $n$-gram pipelines, and combining Induction-Gram with retrieval-augmented generation (RAG).

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.
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},
}

Loading related content...

Figure