Papers › Steering Llama 2 via Contrastive Activation Addition

Steering Llama 2 via Contrastive Activation Addition

9 Dec 2023arXiv:2312.06681archive 2025-07-28

Nina Panickssery, Nick Gabrieli, Julian Schulz, Meg Tong, Evan Hubinger, Alexander Matt Turner

We introduce Contrastive Activation Addition (CAA), an innovative method for steering language models by modifying their activations during forward passes. CAA computes "steering vectors" by averaging the difference in residual stream activations between pairs of positive and negative examples of a particular behavior, such as factual versus hallucinatory responses. During inference, these steering vectors are added at all token positions after the user's prompt with either a positive or negative coefficient, allowing precise control over the degree of the targeted behavior. We evaluate CAA's effectiveness on Llama 2 Chat using multiple-choice behavioral question datasets and open-ended generation tasks. We demonstrate that CAA significantly alters model behavior, is effective over and on top of traditional methods like finetuning and system prompt design, and minimally reduces capabilities. Moreover, we gain deeper insights into CAA's mechanisms by employing various activation space interpretation methods. CAA accurately steers model outputs and sheds light on how high-level concepts are represented in Large Language Models (LLMs).

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2312.06681")

Code

Syntology Ran 14 of 22 code samples harvested from 4 repositories linked to this paper; 8 have no recorded run. Of those that ran: 2 ran · honoured contract; 12 ran with no contract checked.

By repository: official repository: 14 samples from 3 repositories, 13 ran; community (archive-listed): 8 samples from 1 repository, 1 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

nrimsky/caa officialmentioned in paperpytorchMIT report
nrimsky/sycophancysteering officialmentioned in paperpytorchMIT report
wusche1/caa_hallucination officialmentioned in paperpytorch report
steering-vectors/steering-vectors mentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

22 samples harvested; 14 ran; 2 honoured the contract we drafted; 8 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · honoured contract
12ran
8unverified

Licence: 9 of the 22 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 4 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

average_random_lines wusche1/caa_hallucination/paper/Hallucination/steered/gridsearch_script.py official repository ran fingerprinted no licence file found · pointer only · 16b5463363d55f62 · report
create_paired_statements wusche1/caa_hallucination/paper/Hallucination/data_generation/datagen_functions.py official repository ran no licence file found · pointer only · 5c748f6879688dda · report
eval_model nrimsky/sycophancysteering/finetune_llama.py official repository ran · honoured contract MIT (permissive) · 88c6a4e2feade29f · report
extract_data wusche1/caa_hallucination/paper/lib/hallucination_lib.py official repository ran no licence file found · pointer only · c6ea479857c46dbd · report
find_token_ids_for_letter wusche1/caa_hallucination/paper/lib/hallucination_lib.py official repository ran no licence file found · pointer only · bee6eb80fc9ce139 · report
find_token_ids_for_letter wusche1/caa_hallucination/paper/Hallucination/MMLU/create_MMLU_script.py official repository ran no licence file found · pointer only · b22334a879b672d4 · report
get_avg_key_prob nrimsky/caa/plot_results.py official repository ran MIT (permissive) · 71c7b7baeb271dad · report
get_avg_score nrimsky/caa/plot_results.py official repository ran fingerprinted MIT (permissive) · 3aa6e9883f5ac3a5 · report
get_mmlu_questions wusche1/caa_hallucination/paper/Hallucination/MMLU/create_MMLU_script.py official repository ran no licence file found · pointer only · c7d81e3b714024ee · report
get_raw_data_path nrimsky/caa/behaviors.py official repository ran MIT (permissive) · 322dd0b812140661 · report
get_vector_dir nrimsky/caa/behaviors.py official repository ran MIT (permissive) · 252f5af9f6d9f586 · report
question_dataset_to_steering_dataset wusche1/caa_hallucination/paper/Hallucination/steering_vectors/steering_vector_creation_script.py official repository ran no licence file found · pointer only · 33007ecbcf4f097a · report
tokenize_batch_ab wusche1/caa_hallucination/paper/lib/hallucination_lib.py official repository ran no licence file found · pointer only · b732a1ed58c5caf2 · report
build_HOCUS_dataset wusche1/caa_hallucination/paper/Hallucination/data_generation/datagen_functions.py official repository unverified no licence file found · pointer only · 670eaf5a4aadba52 · report
untuple_tensor steering-vectors/steering-vectors/steering_vectors/torch_utils.py community (archive-listed) ran · honoured contract fingerprinted MIT (permissive) · 0d1b4b7a64984981 · report
adjust_read_indices_for_padding steering-vectors/steering-vectors/steering_vectors/token_utils.py community (archive-listed) unverified MIT (permissive) · e7c337a7d8850d10 · report
collect_matching_layers steering-vectors/steering-vectors/steering_vectors/layer_matching.py community (archive-listed) unverified MIT (permissive) · ec984213a0e4f425 · report
find_attention_start_and_end_positions steering-vectors/steering-vectors/steering_vectors/token_utils.py community (archive-listed) unverified MIT (permissive) · 3abe74fe6527e900 · report
get_layer_name steering-vectors/steering-vectors/steering_vectors/layer_matching.py community (archive-listed) unverified MIT (permissive) · de4f85e859799286 · report
get_module steering-vectors/steering-vectors/steering_vectors/torch_utils.py community (archive-listed) unverified MIT (permissive) · f212fc11c8550e27 · report
get_num_matching_layers steering-vectors/steering-vectors/steering_vectors/layer_matching.py community (archive-listed) unverified MIT (permissive) · 26e328c0c4dcd10f · report
logistic_aggregator steering-vectors/steering-vectors/steering_vectors/aggregators.py community (archive-listed) unverified MIT (permissive) · f66d8b185c1e247d · report

Tasks

Multiple-choice

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections