SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2308.10248 · 2023

Steering Language Models With Activation Engineering

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2308.10248.json · badge: /api/ran/2308.10248.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
montemac/activation_additions canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
add_metric_cols Ran
ran; our contract draft was wrong, not the code
montemac/activation_additions/activation_additions/metrics.py
code served (permissive licence) · get_code("b4f8d628ed769cb0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import torch
import numpy as np
from typing import Dict, List, Optional, Union, Iterable

torch.manual_seed(0)

# Create a simple DataFrame with text columns
data = pd.DataFrame({
    'prompts': ['Hello world', 'How are you'],
    'completions': [' response 1', ' response 2'],
})

# Define simple metric functions for text
def text_metric_1(texts: Iterable[str], show_progress: bool, index: Optional[pd.Index]) -> pd.DataFrame:
    """Simple text metric that counts characters"""
    texts_list = list(texts)
    result = pd.DataFrame({
        'char_count': [len(t) for t in texts_list],
        'word_count': [len(t.split()) for t in texts_list],
    }, index=index)
    return result

def text_metric_2(texts: Iterable[str], show_progress: bool, index: Optional[pd.Index]) -> pd.DataFrame:
    """Simple text metric that checks length"""
    texts_list = list(texts)
    result = pd.DataFrame({
        'is_long': [len(t) > 10 for t in texts_list],
    }, index=index)
    return result

# Create metrics dict with text metrics
metrics_dict = {
    'text_stats': text_metric_1,
    'text_length': text_metric_2,
}

# Define ARGS dict with all parameters
ARGS = {
    'data': data,
    'metrics_dict': metrics_dict,
    'cols_to_use': ['prompts', 'completions'],
    'show_progress': False,
    'prefix_cols': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jaxtyping, numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
fwd_hooks_from_activ_hooks Ran
ran; our contract draft was wrong, not the code
montemac/activation_additions/activation_additions/lenses.py
code served (permissive licence) · get_code("e685cc39acaae19b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function takes activ_hooks which is a dict mapping hook names (strings) to lists of hook functions
# The function iterates through items() and then iterates through the list of hook_fns
# So we need a dict where keys are strings (hook names) and values are lists of callables (hook functions)

def dummy_hook_fn_1(x):
    """Dummy hook function 1"""
    return x

def dummy_hook_fn_2(x):
    """Dummy hook function 2"""
    return x * 2

def dummy_hook_fn_3(x):
    """Dummy hook function 3"""
    return x + 1

activ_hooks = {
    'blocks.47.hook_resid_pre': [dummy_hook_fn_1, dummy_hook_fn_2],
    'blocks.48.hook_resid_post': [dummy_hook_fn_3],
}

ARGS = {
    'activ_hooks': activ_hooks,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_function_args Ran
ran; our contract draft was wrong, not the code
montemac/activation_additions/activation_additions/logging.py
code served (permissive licence) · get_code("94fe13d1c85c5bce")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import inspect
from typing import Callable, List

torch.manual_seed(0)

def get_function_args(func: Callable) -> List[str]:
    """Return names of function arguments that aren't *args or **kwargs."""
    signature = inspect.signature(func)
    return [param.name for param in signature.parameters.values() if param.kind not in (inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD)]

# Create a simple test function to pass as the argument
def sample_function(a, b, c=5, *args, **kwargs):
    """A sample function with various parameter types."""
    return a + b + c

ARGS = {
    "func": sample_function
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
logits_to_probs_numpy Ran
ran; our contract draft was wrong, not the code
montemac/activation_additions/activation_additions/logits.py
code served (permissive licence) · get_code("497c3c13a71df2f9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function takes logits as a torch.Tensor and converts them to probabilities
# using torch.distributions.Categorical. We need to provide a valid logits tensor.
# Logits should be a 2D tensor (batch_size, num_classes) or 1D tensor (num_classes)

logits = torch.randn(2, 4)  # batch_size=2, num_classes=4

ARGS = {
    "logits": logits
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
renorm_probs Ran
ran; our contract draft was wrong, not the code
montemac/activation_additions/activation_additions/logits.py
code served (permissive licence) · get_code("6ba41b5aaa31756c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import numpy as np

# Create a simple DataFrame with probability-like values
# Rows represent samples, columns represent classes/categories
data = {
    'class_A': [0.2, 0.3],
    'class_B': [0.3, 0.4],
    'class_C': [0.5, 0.3]
}
probs_df = pd.DataFrame(data)

ARGS = {
    'probs': probs_df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
trajectory_log_probs Ran
ran; our contract draft was wrong, not the code
montemac/activation_additions/activation_additions/lenses.py
code served (permissive licence) · get_code("b5bc96fcc678d944")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class TunedLens(nn.Module):
    def __init__(self, num_layers=3, hidden_dim=4, vocab_size=5):
        super().__init__()
        self.num_layers = num_layers
        self.layers = nn.ModuleList([
            nn.Linear(hidden_dim, vocab_size) for _ in range(num_layers)
        ])
    
    def forward(self, x, layer_idx):
        return self.layers[layer_idx](x)

tuned_lens = TunedLens(num_layers=3, hidden_dim=4, vocab_size=5)

# Create a cache dict with residual streams at different layers
batch_size = 2
hidden_dim = 4
cache = {
    'layer_0_resid_pre': torch.randn(batch_size, hidden_dim),
    'layer_1_resid_pre': torch.randn(batch_size, hidden_dim),
    'layer_2_resid_pre': torch.randn(batch_size, hidden_dim),
}

# Create logits from the model output
vocab_size = 5
logits = torch.randn(batch_size, vocab_size)

ARGS = {
    'tuned_lens': tuned_lens,
    'logits': logits,
    'cache': cache,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 3, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
effectiveness Not yet run
unverified (harvested, no recorded run)
montemac/activation_additions/activation_additions/logits.py
code served (permissive licence) · get_code("45cf3ae9305a773b")
How it ran

no invocation recorded.

preserve_rng_state Not yet run
unverified (harvested, no recorded run)
montemac/activation_additions/activation_additions/completion_utils.py
code served (permissive licence) · get_code("489fbebd4aa24963")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Prompt engineering and finetuning aim to maximize language model performance on a given metric (like toxicity reduction). However, these methods do not fully elicit a model's capabilities. To reduce this gap, we introduce activation engineering: the inference-time modification of activations in order to control (or steer) model outputs. Specifically, we introduce the Activation Addition (ActAdd) technique, which contrasts the intermediate activations on prompt pairs (such as "Love" versus "Hate") to compute a steering vector (Subramani et al. 2022). By tactically adding in e.g. the "Love" - "Hate" steering vector during the forward pass, we achieve SOTA on negative-to-positive sentiment shift and detoxification using models including LLaMA-3 and OPT. ActAdd yields inference-time control over high-level output properties (like topic and sentiment) while preserving performance on off-target tasks. ActAdd is lightweight: it does not require any machine optimization and works with a single pair of data points, which enables rapid iteration over steering. ActAdd demonstrates the power of activation engineering.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2308.10248")
get_code_for_paper("2308.10248")
have("2308.10248")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2308.10248.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2308.10248.svg)](https://syntology.ai/paper/2308.10248)

Connect an agent — have() is free.