Function Vectors
70 beliefs (70 IN, 0 OUT)
The topic "Function Vectors" encompasses a family of results showing that transformer models encode discrete task-execution functions as compact vector quantities in their activation spaces, and that these vectors can be extracted, injected, composed, and even translated across incompatible embedding spaces. Three research threads contribute to this picture. Todd et al., published at ICLR 2024 (fv-iclr2024-publication), define Function Vectors (FVs) as sums of mean task-conditioned activations over a small set of attention heads identified via causal mediation analysis, with causal effects peaking when the vector is injected at roughly one-third of model depth (fvs-constructed-from-middle-layer-attention-heads, fv-optimal-injection-layer-third-of-depth). Hendel et al. (2023) independently show that a single hidden-state vector at an intermediate layer, extracted from the separator token of in-context demonstrations, suffices to drive task execution across 18 tasks in four categories, establishing what they call a "task vector" in activation space as distinct from the weight-space task arithmetic of Ilharco et al. (hendel-task-arithmetic-ilharco-2023, hendel-2023-task-vector-activation-space). Finally, Jha et al. at NeurIPS 2025 (vec2vec-published-neurips-2025-arxiv) push the idea further by demonstrating that functional information encoded in one embedding space can be translated into an entirely incompatible space without paired data or encoder access, treating vectors as carriers of transformable semantic content.
The Todd et al. FV results are the most mechanistically detailed. Extraction selects heads by ranking average indirect effect over 25 corrupted 10-shot prompts, then averages task-conditioned activations over 100 clean 10-shot prompts (fv-extraction-uses-100-clean-prompts, fv-extraction-head-count-gptj). The number of heads in the FV-transporting set scales roughly proportionally to model size, from 10 heads in GPT-J to 100 in Llama 2 70B (fv-head-count-scales-with-model-size, fv-head-set-sizes-by-model), while the maximum per-head AIE actually decreases in larger models (fv-max-aie-decreases-with-model-size), suggesting larger models distribute the same function across more heads. High-AIE heads cluster in middle layers across GPT-J, Llama 2, and GPT-NeoX, with some overlap with known induction heads (fv-gptneoxx-middle-layer-clustering, fv-top10-gptj-induction-heads). A key negative result is that FVs are not merely vocabulary-boosting offsets: reconstructing a vector from its top 50k decoded tokens yields poor task accuracy (fv-decoded-vocabulary-insufficiency), and a vector matching the FV's output distribution in near-zero KL divergence still fails to recover task performance (fv-vocabulary-reconstruction-fails). A related impossibility result shows no constant offset can implement a cyclic mapping like antonymy, since applying it twice would force the offset to zero (fv-cyclic-mapping-impossibility-proof). Positively, FVs are portable across 20 in-context templates and natural-language completions (fv-portability-across-20-templates, fv-singular-plural-natural-text-portability), and they support partial vector algebra in which, for example, Last-Capital equals Last-Copy plus First-Capital minus First-Copy (fv-vector-algebra-composition). The injection formula h'_k = h_k + sum over selected heads at that layer (fv-alternative-multilayer-injection-formula) and the vocabulary-space causal-effect metric delta-logprob (fv-deltalogprob-formula) provide the operational definitions. FVs exert near-zero effect when injected at late layers, confirming they trigger intermediate feed-forward computations rather than acting on output logits (fv-late-layer-near-zero-effect), a pattern explicitly contrasted with Merullo et al.'s late-layer vector offsets (fv-merullo-contrast-late-vs-mid-layer). The research was supported by Open Philanthropy, NSF, and CAIS (fv-funding-sources), and experiments span GPT-J, GPT-NeoX, and Llama 2 at multiple scales (fv-models-tested).
The Hendel et al. thread complements this from a more task-level perspective. Their task vector theta is a single intermediate hidden state extracted at one specific layer L using a dummy query to ensure query-agnosticism (hendel-2023-task-vector-from-arrow-token, hendel-task-vector-single-intermediate-hidden-state). The optimal boundary layer L sits at a similar relative fraction of depth regardless of total model size, echoing Todd et al.'s one-third-depth finding (hendel-2023-layer-l-relative-position, fv-optimal-injection-layer-third-of-depth). Patching theta at layer L is equivalent to blocking attention to the in-context demonstrations in all layers above L, tying the vector to a specific causal pathway (hendel-2023-patching-equivalent-to-attention-masking). A striking result is that injecting a task vector for Task B into a prompt containing demonstrations for Task A causes the model to follow the vector with 77 to 95 percent accuracy, overriding the in-context examples (hendel-conflicting-task-overrides-demonstrations, hendel-conflicting-task-accuracy-range). Vocabulary projections of theta surface tokens like "English" or "participle" that never appeared verbatim in the prompt, indicating an abstracted task representation (hendel-vocabulary-projection-not-verbatim, hendel-vocabulary-projection-fr-en-tokens). t-SNE plots of 50 vectors per task show tight within-task clusters separated from cross-task clusters (hendel-t-sne-50-vectors-per-task-llama7b). The authors explicitly note they do not provide a mechanistic account of how the transformer constructs theta or uses it (hendel-no-mechanism-explanation), and scope their model to single-token-output tasks, leaving multi-step reasoning open (hendel-scope-single-token-output). Knowledge tasks draw on the counterfactual dataset from Meng et al. 2022 (hendel-knowledge-data-meng-2022), and the framework is positioned as complementary to Olsson et al.'s induction-head analysis of ICL (hendel-olsson-induction-heads-2022) and to Merullo et al.'s independent demonstration of single-vector function encoding (hendel-merullo-2023-complementary). The work is publicly available at a GitHub repository (hendel-2023-code-repository), and experiments cover LLaMA, GPT-J, and Pythia at multiple sizes (hendel-2023-models-and-tasks, hendel-gpt-j-6b-architecture, hendel-llama-7b-architecture, hendel-llama-13b-architecture, hendel-pythia-2.8b-architecture).
The vec2vec results extend the vector-as-functional-carrier idea to the problem of translating between incompatible embedding spaces. The method uses a modular architecture with space-specific input adapters, a shared MLP backbone with SiLU activations, and output adapters, trained with two-level GAN losses at both latent and output embedding spaces (vec2vec-architecture-input-output-adapters-shared-backbone, vec2vec-mlp-silu-not-cnn-no-spatial-structure, vec2vec-two-level-adversarial-training-latent-and-output). It requires zero paired examples and zero access to the source encoder (vec2vec-no-paired-data-no-encoder-access), positioning it as the first unsupervised cross-model embedding translation method grounded in a constructive version of the Platonic Representation Hypothesis (vec2vec-first-unsupervised-cross-model-embedding-translation). Performance is strong: 50K training embeddings yield cosine similarity 0.74, within 0.01 of the 1M-embedding ceiling, and full vec2vec achieves cosine 0.75 with mean rank 2.64 against a naive baseline rank of 4084 (vec2vec-data-efficiency-50k-near-1m, vec2vec-full-ablation-metrics). On the challenging Qwen-to-GTE cross-backbone pair, where Qwen is 14 times larger than the next model, vec2vec reaches mean rank 2.49 versus 425 for the best optimal-transport baseline (vec2vec-qwen-pair-outperforms-ot-rank-249-vs-425). Ablations show all three generator losses are necessary, with removing the VSP loss dropping cosine to 0.58 and rank near random (vec2vec-vsp-ablation-cos-drop, vec2vec-ablation-all-three-generator-losses-necessary). Translators generalize to unseen encoders (vec2vec-ood-robustness-unseen-encoders), though zero-shot inversion recovers document content in up to 80 percent of emails, raising privacy considerations (vec2vec-inversion-leakage-80-percent-emails-67-percent-tweets). The authors frame their results as a lower bound on inter-representation fidelity (vec2vec-lower-bound-framing), and total training compute was approximately 176 GPU days across 25 fully trained models (vec2vec-training-compute-176-gpu-days). Evaluation spans Natural Questions, TweetTopic, and MIMIC-III with four size categories and five transformer backbones (vec2vec-datasets-nq-2m-tweettopic-8192-mimic-8192).
Across all three threads, every belief in this topic is currently marked IN; no beliefs have been retracted. The beliefs mix premises (formulas, architectural specifications, dataset descriptions, funding attributions) with derived or empirical claims (impossibility proofs, performance metrics, ablation results, portability demonstrations). The unifying insight is that transformer activation-space vectors are not passive representations but active, composable, portable, and translatable carriers of executable functions, a finding that holds whether the vectors are extracted from attention-head activations (Todd et al.), from a single separator-token hidden state (Hendel et al.), or mapped across entirely different embedding spaces (Jha et al.).
-
IN
fv-alternative-multilayer-injection-formula
The alternative multi-layer FV injection is defined as h'_k = h_k + Σ_{(ℓ,j)∈A, ℓ=k} ā^t_ℓj, adding each head's activation to its own layer rather than summing all into one layer. -
IN
fv-cyclic-mapping-impossibility-proof
No constant vector offset can implement a cyclic mapping such as antonymy: if w + v_a = antonym(w) for all w, then applying twice gives w + 2v_a = w, forcing v_a = 0 and w = antonym(w), a contradiction. -
IN
fv-decoded-vocabulary-insufficiency
Reconstructing a Function Vector from its top decoded tokens (even all 50k vocabulary tokens) yields significantly lower task-execution accuracy, indicating FVs carry information beyond their surface decoded vocabulary. -
IN
fv-deltalogprob-formula
The vocabulary-space causal effect is computed as Δlogprob(w_i) = log P(w_i | h_ℓ + v_t) − log P(w_i), which ranks tokens by how much the FV promotes them beyond the baseline distribution. -
IN
fv-extraction-head-count-gptj
For GPT-J, the FV is constructed from |A| = 10 attention heads (where performance plateaus), using 100 clean 10-shot prompts for computing mean activations and 25 corrupted 10-shot prompts per task for computing AIE. -
IN
fv-extraction-uses-100-clean-prompts
FV extraction (Eq. 5) computes v_t as the sum of mean task-conditioned head activations over |P_t| = 100 clean 10-shot prompts, with heads selected by ranking average indirect effect (AIE) over 25 corrupted 10-shot prompts per task. -
IN
fv-funding-sources
The function vector research was supported by Open Philanthropy, NSF (grant 1901117), an NSF Graduate Research Fellowship, a Zuckerman Postdoctoral Fellowship, and computing resources from the Center for AI Safety (CAIS). -
IN
fv-gptneoxx-middle-layer-clustering
High-AIE heads cluster in middle layers across GPT-J, Llama 2, and GPT-NeoX, with GPT-NeoX being an exception that clusters in earlier-middle layers (10–20). -
IN
fv-head-count-scales-with-model-size
The number of attention heads in the FV-transporting set A scales with model size: GPT-J (6B) uses 10 heads, Llama 2 7B uses 20, Llama 2 13B and GPT-NeoX (20B) use 50, and Llama 2 70B uses 100. -
IN
fv-head-set-sizes-by-model
FV extraction uses a small fixed set of attention heads: 10 for GPT-J, 20 for Llama-2 7B, 50 for Llama-2 13B and GPT-NeoX 20B, and 100 for Llama-2 70B, scaled roughly proportionally to total heads. -
IN
fv-iclr2024-publication
The function vector paper by Todd et al. was presented at ICLR 2024 as a peer-reviewed conference publication. -
IN
fv-injection-layer-selection-per-model
FV injection layer selection (≈ |L|/3) is: GPT-J layer 9, GPT-NeoX layer 15, Llama 2 7B layer 11, Llama 2 13B layer 14, Llama 2 70B layer 26. -
IN
fv-late-layer-near-zero-effect
Function vectors exert near-zero causal effect when added at late layers (e.g., layers 90%+ of depth), indicating they trigger computations through intermediate nonlinear feed-forward layers rather than acting on output logits. -
IN
fv-max-aie-decreases-with-model-size
Maximum AIE decreases with model size: GPT-J ≈ 0.053, Llama 2 7B ≈ 0.047, Llama 2 70B ≈ 0.037, despite increasing total head count in larger models. -
IN
fv-merullo-contrast-late-vs-mid-layer
Merullo et al. (2023) describe vector offsets most effective at late layers (resembling embedding offsets), whereas FVs show the opposite pattern with peak causal effects at early/mid layers, establishing a mechanistic distinction. -
IN
fv-models-tested
The function vector experiments were conducted on GPT-J (6B), GPT-NeoX (20B), and Llama 2 (7B/13B/70B). -
IN
fv-optimal-injection-layer-third-of-depth
FV causal effects are maximal at early-to-middle layers (approximately |L|/3): layer 9 for GPT-J (28L), layer 15 for GPT-NeoX (44L), layer 26 for Llama-2 70B (80L), and drop sharply in late layers. -
IN
fv-portability-across-20-templates
Function Vectors extracted from in-context learning demonstrations reliably trigger task execution in zero-shot prompts, natural text completions, and 20 different ICL templates. -
IN
fv-singular-plural-natural-text-portability
The Singular-Plural function vector achieves 72–83% accuracy when injected into natural-language templates versus 0% baseline, confirming it encodes a generalizable function rather than a template-specific artifact. -
IN
fv-top10-gptj-induction-heads
Three of the top-10 AIE heads in GPT-J (layers 8-1, 12-10, 24-6) are induction heads with prefix-matching scores of 0.49, 0.56, and 0.31 respectively, while several other high-AIE heads lack the prefix-matching signature. -
IN
fv-vector-algebra-composition
Function Vectors support partial vector algebra: Last-Capital* = Last-Copy + First-Capital − First-Copy, producing a vector that triggers the composed 'Last-Capital' task. -
IN
fv-vocabulary-reconstruction-fails
Reconstructing a vector that decodes to the same output-word distribution (near-zero KL divergence) as the FV does not recover FV task performance, proving FVs carry information beyond a simple vocabulary-boosting offset. -
IN
fvs-constructed-from-middle-layer-attention-heads
Function Vectors (FVs) are constructed by summing the mean task-conditioned activations of a small fixed set of attention heads identified via causal mediation analysis, with strongest causal effects concentrated in early-to-middle layers (approximately L/3). -
IN
hendel-18-tasks-4-categories
Hendel et al. study 18 tasks across 4 categories: Algorithmic, Translation, Linguistic, and Knowledge. -
IN
hendel-2023-code-repository
Hendel et al. (2023) release their implementation at https://github.com/roeehendel/icl_task_vectors. -
IN
hendel-2023-layer-l-relative-position
Across all tested models in Hendel et al. (2023), the optimal boundary layer L between task-encoding (A) and task-application (f) peaks at a similar relative (fractional) position regardless of total model depth or parameter count. -
IN
hendel-2023-models-and-tasks
Hendel et al. (2023) validate the task-vector decomposition across 18 tasks in 4 categories (algorithmic, translation, linguistic, factual knowledge) using LLaMA 7B/13B/30B, GPT-J 6B, and Pythia 2.8B/6.9B/12B. -
IN
hendel-2023-patching-equivalent-to-attention-masking
Patching θ at layer L during the f forward pass in Hendel et al. (2023) is equivalent (ignoring positional embeddings) to blocking attention to the demonstrations S in all layers above L. -
IN
hendel-2023-task-vector-activation-space
The task vectors in Hendel et al. (2023) are defined in activation space (hidden representations), distinguishing them from the weight-space task vectors of Ilharco et al. (2023) Task Arithmetic. -
IN
hendel-2023-task-vector-from-arrow-token
In Hendel et al. (2023), the task vector θ is extracted as the hidden representation of the '→' (separator) token at an intermediate layer L, computed using a dummy query (e.g., 'Plum') to ensure query-agnosticism. -
IN
hendel-conflicting-next-letter-to-upper
In the conflicting-tasks experiment, the Next Letter → To Upper transition yields 0.92 Regular accuracy and 0.77 Conflicting accuracy. -
IN
hendel-conflicting-present-past-gerund
In the conflicting-tasks experiment, the Present→Past to Gerund transition yields 0.96 Regular accuracy and 0.95 Conflicting accuracy. -
IN
hendel-conflicting-task-accuracy-range
In the conflicting-tasks experiment, injecting θ for Task B alongside demonstrations for Task A yields 77–95% accuracy on Task B, showing θ overrides in-context demonstrations. -
IN
hendel-conflicting-task-overrides-demonstrations
When a task vector for Task B is injected into a prompt containing demonstrations for Task A, the model follows θ (Task B) with high accuracy and largely disregards the in-context demonstrations. -
IN
hendel-gpt-j-6b-architecture
GPT-J 6B has 4096 hidden dimensions, 28 layers, and 16 attention heads. -
IN
hendel-knowledge-data-meng-2022
Knowledge tasks in Hendel et al. use the counterfactual dataset from Meng et al. (2022), linking the work to ROME-style knowledge editing. -
IN
hendel-llama-13b-architecture
LLaMA 13B has 5120 hidden dimensions, 40 layers, and 40 attention heads. -
IN
hendel-llama-7b-architecture
LLaMA 7B has 4096 hidden dimensions, 32 layers, and 32 attention heads. -
IN
hendel-merullo-2023-complementary
Merullo et al. (2023) independently demonstrated that a single vector can encode a learned function; Hendel et al. state the findings are complementary. -
IN
hendel-no-mechanism-explanation
Hendel et al. explicitly do not provide a mechanistic explanation of how the transformer internally constructs θ from S or how θ is used to compute output logits. -
IN
hendel-olsson-induction-heads-2022
Olsson et al. (2022) identified induction heads as a primary mechanistic basis of ICL; the task-vector framework is complementary, offering a higher-level 'what is computed' perspective. -
IN
hendel-pythia-2.8b-architecture
Pythia 2.8B has 2560 hidden dimensions, 32 layers, and 32 attention heads. -
IN
hendel-scope-single-token-output
The single-task-vector model in Hendel et al. applies to simple, single-token-output tasks; complex multi-step reasoning (e.g., arithmetic) may require multiple or higher-dimensional representations. -
IN
hendel-t-sne-50-vectors-per-task-llama7b
Robustness analysis sampled 50 different (S, x′) pairs per task using LLaMA 7B; t-SNE plots showed tight task-specific clusters with within-task distances smaller than cross-task distances. -
IN
hendel-task-arithmetic-ilharco-2023
Ilharco et al. (2023) work with weight-space vectors for task manipulation via task arithmetic; Hendel et al. show that in-context demonstrations produce a similar functional vector in activation space. -
IN
hendel-task-vector-single-intermediate-hidden-state
The task vector θ is a single intermediate hidden-state vector extracted at one specific layer L, not a set of learned weight updates. -
IN
hendel-translation-data-source
Translation task data was derived from the most-frequent words in the frekwencja/most-common-words-multilingual dataset, translated via nltk. -
IN
hendel-vocabulary-projection-fr-en-tokens
Vocabulary projection of θ for FR→EN translation yields top tokens including 'English,' 'translate,' and 'equivalent' that never appeared verbatim in the prompt. -
IN
hendel-vocabulary-projection-not-verbatim
Top projected tokens for tasks (e.g., 'participle' for Present→Gerund, 'English' for FR→EN) were not present verbatim in the context, indicating θ encodes an abstracted task representation rather than a copy of the input. -
IN
vec2vec-10k-substantially-beats-random
10K training embeddings yield cos 0.57 and Rank 1462.21, substantially above the naïve baseline (cos 0.04, Rank 4084.15) on gte→gtr NQ -
IN
vec2vec-ablation-all-three-generator-losses-necessary
Ablating any single generator loss degrades performance severely: removing VSP drops cosine to 0.58 and rank to ~4197 (near random 4096); removing cycle-consistency drops cosine to 0.50; removing the latent-level GAN drops cosine to 0.49. -
IN
vec2vec-architecture-input-output-adapters-shared-backbone
vec2vec uses a modular architecture with space-specific input adapters (A₁, A₂), a shared backbone (T), and output adapters (B₁, B₂), where translation is F₁ = B₂ ∘ T ∘ A₁ and reconstruction is R₁ = B₁ ∘ T ∘ A₁. -
IN
vec2vec-cross-backbone-convergence-3-of-15-vs-14-of-15
GAN-based vec2vec training is seed-sensitive: shared-backbone pairs converge at 80% top-1 for 14/15 random initializations, while cross-backbone pairs converge for only 3/15 within the same epoch budget. -
IN
vec2vec-data-efficiency-50k-embeddings-rank-39
vec2vec produces a functional translator from 50K embeddings (rank ≈ 3.9 vs. random 4096) and still achieves rank ≈ 1462 from only 10K embeddings, indicating data efficiency for cross-space embedding translation. -
IN
vec2vec-data-efficiency-50k-near-1m
50K training embeddings yield cos 0.74, within 0.01 of the 1M-embedding result (cos 0.75), on the gte→gtr NQ 8192-record evaluation -
IN
vec2vec-datasets-nq-2m-tweettopic-8192-mimic-8192
vec2vec is evaluated on Natural Questions (2M train / 65,536 eval, 1M 64-token sequences per source), TweetTopic (8,192 records, 19 topics), and MIMIC-III pseudo-re-identified (8,192 records, 2,673 MedCAT labels), with training models spanning four size categories, five transformer backbones, and two output dimensionalities. -
IN
vec2vec-first-unsupervised-cross-model-embedding-translation
Jha et al. (NeurIPS 2025, Cornell University) propose the first method for translating text embeddings between incompatible vector spaces (e.g., T5-based GTR vs. BERT-based GTE) requiring no paired data, encoders, or predefined alignment sets, leveraging a constructive version of the Platonic Representation Hypothesis originally conjectured for vision. -
IN
vec2vec-full-ablation-metrics
vec2vec (full) achieves cos 0.75, T⁻¹ 0.91, and Rank 2.64 on an 8192-record NQ evaluation against a naïve baseline of cos 0.04 and Rank 4084.15 -
IN
vec2vec-inversion-leakage-80-percent-emails-67-percent-tweets
Zero-shot inversion of vec2vec-translated embeddings recovers document content (names, dates, financial data) in up to 80% of Enron emails and 67% of tweets, with LLM-judge (GPT-4o) information-leakage accuracy of 30–67% across model pairs on a 50-tweet subset. -
IN
vec2vec-lower-bound-framing
The authors explicitly frame their vec2vec translation results as a lower bound on inter-representation translation fidelity, implying room for improvement with better architectures -
IN
vec2vec-mlp-silu-not-cnn-no-spatial-structure
vec2vec uses MLPs with residual connections, layer normalization, and SiLU activations (not CNNs) because text embeddings lack pixel-grid spatial structure; discriminators omit residual connections. -
IN
vec2vec-no-paired-data-no-encoder-access
vec2vec requires zero paired input-output examples across embedding spaces and zero access to the source encoder that produced the input embeddings -
IN
vec2vec-ood-robustness-unseen-encoders
vec2vec translators generalize to unseen documents and unseen source encoders, not just in-distribution data from known models -
IN
vec2vec-ot-baseline-four-algorithms-hungarian-discrete
The oracle-aided optimal transport baseline compares four algorithms—Hungarian (discrete permutation, evaluated only on Top-1 Accuracy), Earth Mover's Distance, Sinkhorn, and Gromov-Wasserstein (entropic and non-entropic variants, multiple hyperparameters)—with continuous methods scored on Top-1, Mean Rank, and Mean Cosine Similarity via barycenter v′ᵢ = (Σⱼ Pᵢⱼ vⱼ) / (Σⱼ Pᵢⱼ). -
IN
vec2vec-performance-cosine-096-perfect-matching-8000
vec2vec achieves cosine similarity up to 0.96 to ground-truth target-space vectors and perfect matching on 8,000+ shuffled embeddings without a pre-supplied candidate set. -
IN
vec2vec-published-neurips-2025-arxiv
vec2vec (Jha et al., 2025) is published at NeurIPS 2025 with arXiv identifier 2505.12540v4, and code is available on GitHub. -
IN
vec2vec-qwen-pair-outperforms-ot-rank-249-vs-425
On the (Qwen, GTE) cross-backbone pair—where Qwen is 14× larger than the next model and 37× larger than GTE—vec2vec achieves mean rank 2.49 versus 425.07 for the best OT baseline, after 20 days of A100 training. -
IN
vec2vec-training-compute-176-gpu-days
Total training compute for the vec2vec experiments was ~176 GPU days across 25 fully-trained models (1–7 days each), 30 partially-trained models (stopped at 2 days), and one Qwen+GTE pair at 20 days on A100 -
IN
vec2vec-two-level-adversarial-training-latent-and-output
vec2vec trains with discriminators at two levels—latent space (D¹ₗ, D²ₗ) and output embedding space (D₁, D₂)—yielding four GAN loss terms: L_GAN(D₁,F₁) + L_GAN(D₂,F₂) + L_GAN(D¹ₗ,T∘A₁) + L_GAN(D²ₗ,T∘A₂). -
IN
vec2vec-vsp-ablation-cos-drop
Removing the VSP loss component degrades cos from 0.75 to 0.58, T⁻¹ to 0.00, and Rank to 4196.64 in the ablation table