Do different prompting methods yield a common task representation in language models?

Guy Davidson, Todd M. Gureckis, Brenden Lake, Adina Williams

When we ask a Large Language Model (LLM) to perform a task—whether by providing a list of examples or issuing a direct instruction—does the model form the same internal "mental" representation of that task? This research investigates whether identical tasks elicited in different ways result in similar neural representations, offering crucial interpretability insights that could eventually aid in steering model behavior.

The Core Problem: Demonstrations vs. Instructions

In-Context Learning (ICL) is the mechanism that allows LLMs to perform new tasks on the fly. We typically trigger this in two ways:

  1. Demonstrations: Giving the model examples (e.g., "Japan: Tokyo, Chile: Santiago, Egypt:").
  2. Instructions: Telling the model directly (e.g., "Map a country to its capital city. Egypt:").

While both methods often yield the same correct output, it has been unclear if they share the same internal machinery. If they do, it suggests a universal "task representation" exists within the model. If they don't, it implies the model has multiple, redundant ways of solving problems. Understanding this distinction is vital for diagnosing why a model fails and for controlling its behavior without relying on complex, token-heavy prompting.

Overview of the Function Vector extraction and intervention process for demonstrations versus instructions.

Methodology: Extracting Function Vectors

The authors leverage and generalize a technique called Function Vectors (FVs)—neural fingerprints of a specific task. The process involves three main steps:

  1. Extraction: Identify specific "key" attention heads that are most active when a model is performing a given task.
  2. Vectorization: Average the activations of these heads into a single vector that represents the essence of the task.
  3. Intervention: Patch this vector into the model's residual stream during a zero-shot query. If the model suddenly performs the task correctly without explicit prompts, the FV successfully captured the task representation.

While previous work focused on FVs derived from demonstrations, this paper successfully extracts instruction function vectors. To ensure they captured true task-specific logic rather than a general "instruction-following" vibe, the researchers developed sophisticated uninformative baselines using random tokens and unrelated text.

Key Insights: Two Paths to the Same Destination

Across 50 diverse linguistic and factual tasks tested on models like Llama-3 and OLMo-2, the researchers uncovered several surprising dynamics about how LLMs process tasks.

Neural Divergence The attention heads that mediate instruction-following are mostly different from those that handle few-shot demonstrations. Rather than converging on a single universal task representation, the model uses distinct, largely non-overlapping neural mechanisms to process instructions versus demonstrations.

Diffuse vs. Localized Mechanisms Demonstration-based task inference tends to be localized to a few high-impact attention heads. In contrast, instruction-based inference is much more diffuse, spreading the task representation across a wider array of components within the model.

Experimental results showing distinct attention heads for instructions vs. demonstrations (A-D) and the resulting accuracy boosts from Function Vector interventions (G-H).

The Role of Post-Training Instruction FVs are weak in "base" models but become highly effective after Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO). Conversely, demonstration-based learning appears more native to the base models. Interestingly, the authors successfully took an instruction FV from a post-trained model and used it to steer a base model, effectively granting the base model instruction-following capabilities it didn't originally possess.

Synergy, Not Redundancy When researchers applied both a demonstration FV and an instruction FV simultaneously, the model performed better than with either alone. This provides a strong theoretical justification for the common prompt engineering practice of providing both an instruction and examples.

Results and Future Directions

The interventions proved highly effective: adding an instruction-based FV to a model increased its zero-shot accuracy on tasks from under 20% to over 50% in the best-performing models.

While this study focused on relatively minimal tasks with short inputs and outputs, it opens an exciting door for "activation steering." By proving that instructions and demonstrations utilize distinct but complementary neural pathways, this research suggests we might eventually control LLMs by injecting task-specific vectors directly into their hidden states, bypassing the need for exhaustive prompt engineering.

Summary updated

BibTeX
@inproceedings{davidson2025do,
  author = {Guy Davidson and Todd M. Gureckis and Brenden Lake and Adina Williams},
  title = {{Do different prompting methods yield a common task representation in language models?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=fy5InEg0OL},
}
Figure