Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Function Vectors in Large Language Models

About

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. We investigate the internal structure of FVs and find while that they often contain information that encodes the output space of the function, this information alone is not sufficient to reconstruct an FV. Finally, we test semantic vector composition in FVs, and find that to some extent they can be summed to create vectors that trigger new complex tasks. Our findings show that compact, causal internal vector representations of function abstractions can be explicitly extracted from LLMs. Our code and data are available at https://functions.baulab.info.

Eric Todd, Millicent L. Li, Arnab Sen Sharma, Aaron Mueller, Byron C. Wallace, David Bau• 2023

Related benchmarks

TaskDatasetResultRank
Multitask Language UnderstandingMMLU-Pro
Accuracy1.14
118
Natural Language InferenceaNLI
Accuracy0.00e+0
65
Semantic Antonym PredictionAntonym
Accuracy65.7
44
Machine TranslationEnglish-French
Accuracy75.2
42
ReasoningBig-Bench Hard (BBH)
Accuracy17.82
33
Knowledge Retrieval / Relation PredictionPerson-Instrument
Accuracy0.722
30
In-Context LearningNLP Task Suite (Capitalize, Country-Capital, Present-Past, Singular-Plural, Person-Sport, AG News) (test)
Capitalize99.7
20
Word Relation PredictionPerson-Occupation
Accuracy54.2
20
Word Relation PredictionProduct-Company
Accuracy76
20
Word Relation PredictionLandmark-Continent
Accuracy84.2
20
Showing 10 of 31 rows

Other info

Follow for update