2023

Function Vectors in Large Language Models

Todd, Eric, Li, Millicent L., Sharma, Arnab Sen et al.

Understand

We report the presence of a simple neural mechanism that represents an input-output function as a vector within autoregressive transformer language models (LMs).

  • Using causal mediation analysis on a diverse range of in-context-learning (ICL) tasks, we find that a small number attention heads transport a compact representation of the demonstrated task, which we call a function vector (FV).
  • FVs are robust to changes in context, i.e., they trigger execution of the task on inputs such as zero-shot and natural text settings that do not resemble the ICL contexts from which they are collected.
  • We test FVs across a range of tasks, models, and layers and find strong causal effects across settings in middle layers.

Reading the bibliography…