SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.16090 · NeurIPS · 2024

Analysing the Residual Stream of Language Models Under Knowledge Conflicts

Pasquale Minervini, Xuanli He, Hongru Wang, Alessio Devoto, Yu Zhao, Xiaotang Du, Giwon Hong, Aryo Pradipta, Kam-Fai Wong

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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; 5 failures of our instrument; 2 no recorded run), measured 2026-11-24; 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/2410.16090.json · badge: /api/ran/2410.16090.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
yuzhaouoe/sae-based-representation-engineering canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
FunctionStatusWhere it lives
assert_type Ran
ran; our contract draft was wrong, not the code
yuzhaouoe/sae-based-representation-engineering/spare/sae/utils.py
code served (permissive licence) · get_code("94434469ea2ebc0d")
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 str. 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
import torch.nn as nn
from typing import Type, TypeVar, Any, cast

torch.manual_seed(0)

T = TypeVar('T')

def assert_type(typ: Type[T], obj: Any) -> T:
    """Assert that an object is of a given type at runtime and return it."""
    if not isinstance(obj, typ):
        raise TypeError(f'Expected {typ.__name__}, got {type(obj).__name__}')
    return cast(typ, obj)


# Setup: Create valid arguments for assert_type
# The function takes a Type and an object, and asserts the object is an instance of that type

# Test case 1: Simple type assertion with str
test_string = "hello"
test_type = str

ARGS = {
    "typ": test_type,
    "obj": test_string
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
geometric_median Ran
ran; our contract draft was wrong, not the code
yuzhaouoe/sae-based-representation-engineering/spare/sae/utils.py
code served (permissive licence) · get_code("f4ce8ed89c978106")
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 (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
from torch import Tensor

torch.manual_seed(0)

# Create a small tensor of points for the geometric_median function
# Shape: (batch_size=2, dim=4)
points = torch.randn(2, 4)

ARGS = {
    "points": points,
    "max_iter": 100,
    "tol": 1e-05,
}
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 (4,) — shape (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_columns_all_equal Ran
ran; our contract draft was wrong, not the code
yuzhaouoe/sae-based-representation-engineering/spare/sae/data.py
pointer only (licence: MIT); the stored copy get_code serves, from Teddy-XiongGZ/RAGLens, is pointer only (licence: NONE) · get_code("b44a86959a6f33aa")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Teddy-XiongGZ/RAGLens, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_sae_activations Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
yuzhaouoe/sae-based-representation-engineering/spare/sae_repe_utils.py
code served (permissive licence) · get_code("4fa937f1bbb0955d")
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 3, dtype family float, shape (2, 2, 3) 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
import torch.nn as nn

torch.manual_seed(0)

# Create a simple SAE module that has a pre_acts method
class SimpleSAE(nn.Module):
    def __init__(self, input_dim, output_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def pre_acts(self, hidden):
        # pre_acts should take a hidden tensor and return activations
        return self.linear(hidden)

# Create SAE instance
sae = SimpleSAE(input_dim=4, output_dim=3)

# Create hiddens as a list of tensors (iterable of batches)
# Each hidden should be a tensor that can be passed to sae.pre_acts
hiddens = [
    torch.randn(2, 4),  # batch of 2, dimension 4
    torch.randn(2, 4),  # batch of 2, dimension 4
]

ARGS = {
    "hiddens": hiddens,
    "sae": sae,
    "disable_tqdm": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 2, 3) — shape (2, 2, 3) 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
sample_train_data Ran
ran; our contract draft was wrong, not the code
yuzhaouoe/sae-based-representation-engineering/spare/sae_repe_utils.py
code served (permissive licence) · get_code("79266654f8fb18fb")
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
import numpy as np

torch.manual_seed(0)

# Create small hidden state tensors
label0_hiddens = torch.randn(5, 4)  # 5 examples, 4-dim hidden states
label1_hiddens = torch.randn(5, 4)  # 5 examples, 4-dim hidden states

# Create sample prediction answer data
pred_sub_answer_data = ["sub_answer_0", "sub_answer_1", "sub_answer_2", "sub_answer_3", "sub_answer_4"]
pred_org_answer_data = ["org_answer_0", "org_answer_1", "org_answer_2", "org_answer_3", "org_answer_4"]

# Define arguments dict
ARGS = {
    'label0_hiddens': label0_hiddens,
    'label1_hiddens': label1_hiddens,
    'pred_sub_answer_data': pred_sub_answer_data,
    'pred_org_answer_data': pred_org_answer_data,
    'num_train_examples': 3,
    'seed': 42
}
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 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
chunk_and_tokenize Not yet run
unverified (harvested, no recorded run)
yuzhaouoe/sae-based-representation-engineering/spare/sae/data.py
pointer only (licence: MIT); the stored copy get_code serves, from Teddy-XiongGZ/RAGLens, is pointer only (licence: NONE) · get_code("3fafa18bde72510f")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Teddy-XiongGZ/RAGLens, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

get_layer_list Not yet run
unverified (harvested, no recorded run)
yuzhaouoe/sae-based-representation-engineering/spare/sae/utils.py
code served (permissive licence) · get_code("93cb4a2a9043bc2c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 3 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
assert_type 5 other papers
3 dated earlier, 2 later
2303.08112 (2023-03)
Eliciting Latent Predictions from Transformers with the Tuned Lens
2312.01037 (2023-12)
Eliciting Latent Knowledge from Quirky Language Models
2406.04093 (2024-06)
Scaling and evaluating sparse autoencoders
and 2 more not named here
get_columns_all_equal 4 other papers
2 dated earlier, 2 later
2303.08112 (2023-03)
Eliciting Latent Predictions from Transformers with the Tuned Lens
2406.04093 (2024-06)
Scaling and evaluating sparse autoencoders
2501.18823 (2025-01)
Transcoders Beat Sparse Autoencoders for Interpretability
and 1 more not named here
chunk_and_tokenize 3 other papers
1 dated earlier, 2 later
2406.04093 (2024-06)
Scaling and evaluating sparse autoencoders
2501.18823 (2025-01)
Transcoders Beat Sparse Autoencoders for Interpretability
2512.08892 (2025-12)
Toward Faithful Retrieval-Augmented Generation with Sparse Autoencoders

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

Repositories linked to this paper

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

Abstract

Large language models (LLMs) can store a significant amount of factual knowledge in their parameters. However, their parametric knowledge may conflict with the information provided in the context. Such conflicts can lead to undesirable model behaviour, such as reliance on outdated or incorrect information. In this work, we investigate whether LLMs can identify knowledge conflicts and whether it is possible to know which source of knowledge the model will rely on by analysing the residual stream of the LLM. Through probing tasks, we find that LLMs can internally register the signal of knowledge conflict in the residual stream, which can be accurately detected by probing the intermediate model activations. This allows us to detect conflicts within the residual stream before generating the answers without modifying the input or model parameters. Moreover, we find that the residual stream shows significantly different patterns when the model relies on contextual knowledge versus parametric knowledge to resolve conflicts. This pattern can be employed to estimate the behaviour of LLMs when conflict happens and prevent unexpected answers before producing the answers. Our analysis offers insights into how LLMs internally manage knowledge conflicts and provides a foundation for developing methods to control the knowledge selection processes.

For agents

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

get_harvested_code_for_paper("2410.16090")
get_code_for_paper("2410.16090")
have("2410.16090")

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

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

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

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

Connect an agent — have() is free.