NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Query Circuits: Explaining How Language Models Answer User Prompts

Tung-Yu Wu, Fazl Barez

Introduction

In the field of mechanistic interpretability, researchers often search for "capability circuits"—general-purpose sub-networks that handle broad tasks like arithmetic or grammar. While valuable, these global circuits do not explain why a model produces a specific, sometimes incorrect, answer to a unique, real-world prompt.

Existing methods for "local" or input-level explanations typically rely on surrogate models like Sparse Autoencoders (SAEs). However, these surrogates are computationally expensive to train and may not perfectly reflect the original model's internal logic. To address this, researchers have introduced Query Circuits, a method to directly trace the specific information flow within a Large Language Model (LLM) responsible for answering a single prompt.

Finding these circuits directly within the model presents two major hurdles:

  1. Metric Instability: Standard metrics like the Normalized Faithfulness Score (NFS) fluctuate wildly on complex datasets, making it difficult to verify if a discovered circuit is truly faithful to the original model.
  2. Gradient Noise: Calculating the importance of a single connection for a single prompt is inherently noisy. A connection might appear crucial for one phrasing but irrelevant for another, even if the underlying logic remains identical.

Methodology: Discovering Query Circuits

To overcome these challenges, the authors propose an "in-place" framework that operates directly within the original model, utilizing two novel techniques:

  • Normalized Deviation Faithfulness (NDF): The authors introduce NDF as a robust, stable metric for evaluating circuits. Bounded between 0 and 1, NDF treats deviations above and below the model's original performance equally, making it highly reliable for complex benchmarks like MMLU.
  • Best-of-N (BoN) Sampling: Inspired by the "Lottery Ticket Hypothesis," this strategy combats gradient noise by generating several paraphrases of the original prompt. The system finds candidate circuits for each paraphrase and the original prompt, ultimately selecting the "winning ticket"—the circuit that most faithfully recovers the model's original output on the target query.

To make this process computationally viable across different edge budgets, the authors also developed interpolation methods (iBoN & BoN-CSM) to quickly estimate circuits of varying sizes without requiring exhaustive passes through the LLM.

Key Insights

The investigation into query circuits reveals several fundamental characteristics of how LLMs process information:

  • Circuit Sparsity: LLMs are often viewed as dense "black boxes," but results indicate that for any given prompt, the vast majority of the model is inactive. Only a tiny, sparse sub-network does the heavy lifting.
  • The "Winning Ticket" Phenomenon: Surprisingly, a circuit discovered on the original query might fail, while a circuit discovered on a paraphrase of that query often works perfectly for the original. This suggests the "true" circuit exists, but standard attribution methods are too noisy to find it in a single attempt.
  • Shared Sub-circuits: Even when different paraphrases yield different candidate circuits, they almost always share a core sub-circuit. This core represents the fundamental logic the model uses to solve the problem, regardless of phrasing.

Empirical Results

The authors evaluated their methods across diverse tasks, including Indirect Object Identification (IOI), Arithmetic, MMLU, the ARC Challenge, and a Gender Bias dataset.

The results demonstrate remarkable efficiency and performance recovery. On the MMLU benchmark, a query circuit containing only 1.3% of the model's edges could recover roughly 60% of the model's performance on a specific question. Furthermore, BoN sampling proved highly efficient: for Llama-3-8B, BoN found a 5,000-edge circuit that was more faithful than a 300,000-edge circuit identified by standard methods.

High NDF scores also translate to real-world actionability. In gender bias experiments, ablating features within the "best" (highest NDF) circuits led to a significantly larger reduction in model bias compared to ablating features in lower-scoring circuits, proving that NDF is a reliable proxy for circuit quality and steerability.

Limitations and Future Directions

While query circuits represent a significant step forward, the current framework has limitations. It is currently optimized for queries resulting in single-token outputs (like multiple-choice answers), making long-form, multi-token generation a challenge for future work. Additionally, the edge-scoring method evaluates connections somewhat in isolation, potentially missing complex combinatorial interactions between edges.

Finally, while the method successfully isolates the structural edges of the circuit, making the nodes human-readable still requires manual inspection or integration with SAEs. Future research aims to automate the labeling of these circuits to provide instant, natural-language explanations for any user prompt.

Summary updated

BibTeX
@inproceedings{wu2026query,
  author = {Tung-Yu Wu and Fazl Barez},
  title = {{Query Circuits: Explaining How Language Models Answer User Prompts}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=7F0sragazb},
}
Figure