SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.01405 · 2023

Representation Engineering: A Top-Down Approach to AI Transparency

Matt Fredrikson, Dan Hendrycks, Steven Basart, Andy Zou, Mantas Mazeika, Zifan Wang, Dawn Song, Zico Kolter, Alex Mallen, Alexander Pan, Sanmi Koyejo, Long Phan, and 9 more

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 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 1 has no contract verdict; 5 failures of our instrument; 4 no recorded run), measured 2026-11-22; 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/2310.01405.json · badge: /api/ran/2310.01405.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
andyzoujm/representation-engineering canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
FunctionStatusWhere it lives
compute_loss Ran
ran; our contract draft was wrong, not the code
andyzoujm/representation-engineering/lorra_finetune/src/llama2_lorra.py
code served (permissive licence) · get_code("acc281fc1d7b77bc")
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 Tensor, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 gc
import torch
import torch.nn as nn


torch.manual_seed(0)


class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.lora_enabled = True
        # Create a simple transformer-like model that outputs hidden states
        self.embedding = nn.Embedding(100, 4)
        self.layers = nn.ModuleList([nn.Linear(4, 4) for _ in range(5)])
    
    def forward(self, input_ids, attention_mask=None, output_hidden_states=False):
        x = self.embedding(input_ids)
        hidden_states = [x]
        
        for layer in self.layers:
            x = layer(x)
            hidden_states.append(x)
        
        result = {}
        if output_hidden_states:
            result['hidden_states'] = hidden_states
        return result
    
    def disable_adapter(self):
        class ContextManager:
            def __enter__(self):
                return self
            def __exit__(self, *args):
                pass
        return ContextManager()
    
    def train(self, mode=True):
        super().train(mode)
        self.lora_enabled = True
        return self
    
    def eval(self):
        super().eval()
        self.lora_enabled = False
        return self


# Create model instance
model = MockModel()

# Create inputs: (batch_size=2, num_variants=3, seq_len=10)
batch_size = 2
seq_len = 10
num_variants = 3

input_ids = torch.randint(0, 100, (batch_size, num_variants, seq_len))
attention_mask = torch.ones(batch_size, num_variants, seq_len)

inputs = {
    'input_ids': input_ids,
    'attention_mask': attention_mask
}

# Target layers to extract hidden states from
target_layers = [1, 2, 3]

# Hyperparameters
alpha = 0.5
beta = 0.3

ARGS = {
    'self': model,
    'model': model,
    'inputs': inputs,
    'target_layers': target_layers,
    'alpha': alpha,
    'beta': beta,
    'max_res_len': 64,
    'return_outputs': False
}
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 Tensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (read:RecursionError)
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_position_ids Ran
ran; our contract draft was wrong, not the code
andyzoujm/representation-engineering/lorra_finetune/src/train_val_datasets.py
code served (permissive licence) · get_code("db75f13051c04007")
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 Tensor, ndim 2, dtype family int, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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

torch.manual_seed(0)

# attention_mask is a tensor with values 0 and 1
# The function calls .long(), .cumsum(-1), .masked_fill_()
# So we need a 2D tensor (batch_size=2, seq_len=4) with 0s and 1s
attention_mask = torch.tensor([
    [1, 1, 1, 0],
    [1, 1, 0, 0]
], dtype=torch.float32)

ARGS = {
    "attention_mask": attention_mask
}
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 Tensor, ndim 2, dtype family int, shape (2, 4) — shape (2, 4) as a later run recorded it
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_truncated_outputs Ran
ran on a synthesized input
andyzoujm/representation-engineering/lorra_finetune/src/train_val_datasets.py
code served (permissive licence) · get_code("1899aee66262f84f")
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 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

torch.manual_seed(0)

ARGS = {
    'all_outputs': ['This is a response.', 'Another response here.', 'Yet another response.'],
    'prefixes': ['What is AI?', 'Explain machine learning.', 'Describe neural networks.'],
    'num_examples': 2,
    'user_tag': '[USER]',
    'assistant_tag': '[ASSISTANT]',
    'pos_type': 'positive',
    'neg_type': 'negative',
    'control_template': '[{type}]'
}
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 tuple, ndim 2, 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
prepare_inputs Ran
ran; our contract draft was wrong, not the code
andyzoujm/representation-engineering/lorra_finetune/src/train_val_datasets.py
code served (permissive licence) · get_code("97aa4e637d9f5444")
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 dict. 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 torch

torch.manual_seed(0)

# Construct tokenized_text dict with attention_mask tensor
# The function expects a dict with 'attention_mask' key containing a tensor
tokenized_text = {
    'input_ids': torch.tensor([[101, 2054, 2003, 102], [101, 1045, 2572, 102]]),
    'attention_mask': torch.tensor([[1, 1, 1, 1], [1, 1, 0, 0]])
}

device = 'cpu'

ARGS = {
    'tokenized_text': tokenized_text,
    'device': device
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 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
project_onto_direction Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
andyzoujm/representation-engineering/repe/rep_readers.py
code served (permissive licence) · get_code("8c6b734d5c949090")
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 Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type, ndim and shape 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

torch.manual_seed(0)

# H should be a tensor of shape (n, d_1)
H = torch.randn(2, 4)

# direction should be a tensor of shape (d_2,)
direction = torch.randn(4)

ARGS = {
    "H": H,
    "direction": direction,
}
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 Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
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
recenter Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
andyzoujm/representation-engineering/repe/rep_readers.py
code served (permissive licence) · get_code("1ceba3fc481567ab")
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 Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type, ndim and shape 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

torch.manual_seed(0)

# Create a small tensor for x parameter (batch_size=2, features=4)
x_data = torch.randn(2, 4)

# Create a small mean tensor (1, 4) to match the shape expected by the function
mean_data = torch.randn(1, 4)

ARGS = {
    "x": x_data,
    "mean": mean_data
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
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
arc_dataset Not yet run
unverified (harvested, no recorded run)
andyzoujm/representation-engineering/repe_eval/tasks/arc.py
code served (permissive licence) · get_code("18886c949c98a5c9")
How it ran

no invocation recorded.

contrast_greedy_search Not yet run
unverified (harvested, no recorded run)
andyzoujm/representation-engineering/repe/rep_control_contrast_vec.py
code served (permissive licence) · get_code("2b4c9fbd7f2a466f")
How it ran

no invocation recorded.

csqa_dataset Not yet run
unverified (harvested, no recorded run)
andyzoujm/representation-engineering/repe_eval/tasks/csqa.py
code served (permissive licence) · get_code("2ef192a290c2db9a")
How it ran

no invocation recorded.

forward_contrast_vector Not yet run
unverified (harvested, no recorded run)
andyzoujm/representation-engineering/repe/rep_control_contrast_vec.py
code served (permissive licence) · get_code("a953412e8172dfef")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 6 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 6 later) and 4 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.

FunctionAlso present inEarliest-datedOthers named
project_onto_direction 3 other papers
3 later
2405.18727 (2024-05)
CtrlA: Adaptive Retrieval-Augmented Generation via Inherent Control
2410.24190 (2024-10)
Hidden Persuaders: LLMs' Political Leaning and Their Influence on Voters
2025.findings-acl.652 (2025 (year only))
CTRLA: Adaptive Retrieval-Augmented Generation via Inherent Control
recenter 3 other papers
3 later
2405.18727 (2024-05)
CtrlA: Adaptive Retrieval-Augmented Generation via Inherent Control
2410.24190 (2024-10)
Hidden Persuaders: LLMs' Political Leaning and Their Influence on Voters
2025.findings-acl.652 (2025 (year only))
CTRLA: Adaptive Retrieval-Augmented Generation via Inherent Control
arc_dataset 1 other paper
1 later
2410.24190 (2024-10)
Hidden Persuaders: LLMs' Political Leaning and Their Influence on Voters
contrast_greedy_search 1 other paper
1 later
2410.24190 (2024-10)
Hidden Persuaders: LLMs' Political Leaning and Their Influence on Voters
csqa_dataset 1 other paper
1 later
2410.24190 (2024-10)
Hidden Persuaders: LLMs' Political Leaning and Their Influence on Voters
forward_contrast_vector 1 other paper
1 later
2410.24190 (2024-10)
Hidden Persuaders: LLMs' Political Leaning and Their Influence on Voters

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-22.

Repositories linked to this paper

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

Abstract

We identify and characterize the emerging area of representation engineering (RepE), an approach to enhancing the transparency of AI systems that draws on insights from cognitive neuroscience. RepE places representations, rather than neurons or circuits, at the center of analysis, equipping us with novel methods for monitoring and manipulating high-level cognitive phenomena in deep neural networks (DNNs). We provide baselines and an initial analysis of RepE techniques, showing that they offer simple yet effective solutions for improving our understanding and control of large language models. We showcase how these methods can provide traction on a wide range of safety-relevant problems, including honesty, harmlessness, power-seeking, and more, demonstrating the promise of top-down transparency research. We hope that this work catalyzes further exploration of RepE and fosters advancements in the transparency and safety of AI systems. Code is available at github.com/andyzoujm/representation-engineering.

For agents

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

get_harvested_code_for_paper("2310.01405")
get_code_for_paper("2310.01405")
have("2310.01405")

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

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

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

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

Connect an agent — have() is free.