SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2607.26228 · 2026

Steering Instruction Hierarchies at Inference Time

Han Zhao, Sewoong Lee, Siqi Zeng, Julia Hockenmaier

arXiv · PDF · Open in the Atlas

Code that ran

10 of 11 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2607.26228.json · badge: /api/ran/2607.26228.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
cindy2000sh/v-steer community
Papers with Code archive
10 ran · 1 no recorded run
FunctionStatusWhere it lives
_get_o_proj_weight Ran
ran, honoured the contract we drafted
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("b3bea5377fb730e4")
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 Parameter, 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 torch.nn as nn

torch.manual_seed(0)

# Build a minimal HuggingFace-style LM structure
class MinimalAttention(nn.Module):
    def __init__(self, in_features=4, out_features=6):
        super().__init__()
        self.o_proj = nn.Linear(in_features, out_features)
    
    def forward(self, x):
        return self.o_proj(x)

class MinimalSelfAttention(nn.Module):
    def __init__(self):
        super().__init__()
        self.o_proj = nn.Linear(4, 6)
    
    def forward(self, x):
        return self.o_proj(x)

class MinimalLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.self_attn = MinimalSelfAttention()

class MinimalModel(nn.Module):
    def __init__(self, num_layers=2):
        super().__init__()
        self.layers = nn.ModuleList([MinimalLayer() for _ in range(num_layers)])

class MinimalHFLM(nn.Module):
    def __init__(self):
        super().__init__()
        self.model = MinimalModel(num_layers=3)

hf_lm = MinimalHFLM()

ARGS = {
    "hf_lm": hf_lm,
    "L": 1,
    "device": torch.device("cpu"),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
bitsandbytes, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Parameter, ndim 2, dtype family float — no output shape is stated: observe_signature.py recorded Tensor ndim 2, which disagrees with the fixture run
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_token Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("1c8357fef3a872c6")
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 int, shape (2,) 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 transformers import TopPLogitsWarper

torch.manual_seed(0)

# Create a small logits tensor: batch_size=2, vocab_size=4
logits = torch.randn(2, 4)

# Set parameters
temperature = 0.8
top_p = 0.9

ARGS = {
    "logits": logits,
    "temperature": temperature,
    "top_p": top_p,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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 int, 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
extract_v_from_cache Ran
ran; our contract draft was wrong, not the code
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("c5e1b5eccac7fd9a")
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 torch.nn as nn

torch.manual_seed(0)

# Build a mock config with num_hidden_layers
class MockConfig:
    def __init__(self):
        self.num_hidden_layers = 2

config = MockConfig()

# Build mock outputs with past_key_values
# past_key_values should be a list of tuples (k, v) for each layer
# Each k, v should have shape [B, H_kv, T, d_head]
batch_size = 2
num_heads_kv = 3
seq_len = 5
d_head = 4

# Create legacy cache format: list of (k, v) tuples per layer
legacy_cache = []
for layer_idx in range(config.num_hidden_layers):
    k = torch.randn(batch_size, num_heads_kv, seq_len, d_head)
    v = torch.randn(batch_size, num_heads_kv, seq_len, d_head)
    legacy_cache.append((k, v))

# Create a mock outputs object with past_key_values attribute
class MockOutputs:
    def __init__(self, past_key_values):
        self.past_key_values = past_key_values

outputs = MockOutputs(past_key_values=legacy_cache)

ARGS = {
    "outputs": outputs,
    "config": config,
    "seq_len": 5
}
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
generate_hf_with_v_steering Ran
ran; our contract draft was wrong, not the code
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("e146f8177f845b03")
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. 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 Tuple

torch.manual_seed(0)

# Minimal HuggingFace model stand-in
class MinimalHFModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_size=16):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.lm_head = nn.Linear(hidden_size, vocab_size)
        self.vocab_size = vocab_size
        self.hidden_size = hidden_size
    
    def forward(self, input_ids, use_cache=False, past_key_values=None, 
                attention_mask=None, return_dict=False):
        x = self.embedding(input_ids)
        logits = self.lm_head(x)
        
        # Generate dummy KV cache
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        num_heads = 2
        head_dim = self.hidden_size // num_heads
        
        new_kv_cache = []
        for _ in range(2):  # 2 layers
            k = torch.randn(batch_size, num_heads, seq_len, head_dim)
            v = torch.randn(batch_size, num_heads, seq_len, head_dim)
            new_kv_cache.append((k, v))
        
        class Output:
            pass
        
        out = Output()
        out.logits = logits
        out.past_key_values = tuple(new_kv_cache)
        return out

# Minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.eos_token_id = 2
        self.unk_token_id = 0
    
    def convert_tokens_to_ids(self, token_str):
        # Return None for tokens we don't have
        return None

# Minimal KV cache stand-in
class MinimalKVCache:
    def __init__(self, batch_size=2, num_heads=2, seq_len=5, head_dim=8):
        self.cache = []
        for _ in range(2):  # 2 layers
            k = torch.randn(batch_size, num_heads, seq_len, head_dim)
            v = torch.randn(batch_size, num_heads, seq_len, head_dim)
            self.cache.append((k, v))
    
    def crop(self, new_len):
        """Crop cache to new_len sequence length"""
        self.cache = [(k[:, :, :new_len, :], v[:, :, :new_len, :]) 
                      for k, v in self.cache]
    
    def __iter__(self):
        return iter(self.cache)

# Build arguments
hf_model = MinimalHFModel(vocab_size=100, hidden_size=16)
hf_model.eval()

batch_size = 2
prompt_len = 5
input_ids = torch.randint(1, 50, (batch_size, prompt_len))
attention_mask = torch.ones((batch_size, prompt_len), dtype=torch.long)
last_pos = torch.tensor([prompt_len - 1, prompt_len - 1], dtype=torch.long)

kv_cache_steered = MinimalKVCache(batch_size=batch_size, num_heads=2, seq_len=prompt_len, head_dim=8)

tokenizer = MinimalTokenizer()

ARGS = {
    "hf_model": hf_model,
    "input_ids": input_ids,
    "attention_mask": attention_mask,
    "kv_cache_steered": kv_cache_steered,
    "last_pos": last_pos,
    "tokenizer": tokenizer,
    "max_new_tokens": 10,
    "temperature": 0.7,
    "top_p": 0.9
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
get_head_to_kv_map Ran
ran; our contract draft was wrong, not the code
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("2b46b146c6276ed4")
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. 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)

class Config:
    def __init__(self):
        self.num_attention_heads = 8
        self.num_key_value_heads = 2

config = Config()
device = torch.device('cpu')

ARGS = {
    'config': config,
    '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 tuple — a tuple output has no array shape of its own; none is 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
get_legacy_cache Ran
ran, honoured the contract we drafted
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("ca43e1f8af4f09fa")
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 5, 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

torch.manual_seed(0)

# Create a mock cache object with to_legacy_cache method
class MockCache:
    def __init__(self):
        self.key_cache = [torch.randn(2, 4, 3) for _ in range(2)]
        self.value_cache = [torch.randn(2, 4, 3) for _ in range(2)]
    
    def to_legacy_cache(self):
        # Return legacy format: tuple of tuples
        return (
            tuple(self.key_cache),
            tuple(self.value_cache)
        )

# Create test argument
mock_cache = MockCache()

ARGS = {
    "past_key_values": mock_cache
}
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 5, 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
get_stop_token_ids Ran
ran, honoured the contract we drafted
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("b52dcae72b6ea396")
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 int; 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
from transformers import AutoTokenizer

# Create a minimal mock tokenizer that implements the required interface
class MockTokenizer:
    def __init__(self):
        self.unk_token_id = 0
        self.eos_token_id = 2
        self._token_map = {
            '<|eot_id|>': 100,
            '<|start_header_id|>': 101,
            '<|im_end|>': 102,
            '<|im_start|>': 103,
        }
    
    def convert_tokens_to_ids(self, token_str):
        """Convert a token string to its ID, or return unk_token_id if not found."""
        return self._token_map.get(token_str, self.unk_token_id)

tokenizer = MockTokenizer()

ARGS = {
    "tokenizer": tokenizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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 int — 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
select_bad_kv_heads Ran
ran; our contract draft was wrong, not the code
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("0d7c5f116c08eb2a")
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 os

torch.manual_seed(0)

# Create a minimal config class that has the attributes needed
class MockConfig:
    def __init__(self, num_attention_heads=8, num_key_value_heads=2):
        self.num_attention_heads = num_attention_heads
        self.num_key_value_heads = num_key_value_heads

# Create per_head data structure
# per_head is a Dict[int, Dict[str, torch.Tensor]]
# where each layer has 'q_A', 'q_B', 'kv_A', 'kv_B' tensors
batch_size = 2
num_heads = 8

per_head = {
    0: {
        'q_A': torch.randn(batch_size, num_heads),
        'q_B': torch.randn(batch_size, num_heads),
        'kv_A': torch.randn(batch_size, 2),
        'kv_B': torch.randn(batch_size, 2),
    },
    1: {
        'q_A': torch.randn(batch_size, num_heads),
        'q_B': torch.randn(batch_size, num_heads),
        'kv_A': torch.randn(batch_size, 2),
        'kv_B': torch.randn(batch_size, 2),
    },
    2: {
        'q_A': torch.randn(batch_size, num_heads),
        'q_B': torch.randn(batch_size, num_heads),
        'kv_A': torch.randn(batch_size, 2),
        'kv_B': torch.randn(batch_size, 2),
    },
}

config = MockConfig(num_attention_heads=8, num_key_value_heads=2)

ARGS = {
    'per_head': per_head,
    'config': config,
    'eps': 0.1,
}
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
span_dla_from_hf_attn Ran
ran; our contract draft was wrong, not the code
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("f229a0b0136dbdf3")
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 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 torch.nn as nn
from typing import Dict, Tuple

torch.manual_seed(0)

# Build a minimal HF-like language model structure
class MinimalSelfAttention(nn.Module):
    def __init__(self, hidden_size, num_attention_heads, num_key_value_heads):
        super().__init__()
        self.hidden_size = hidden_size
        self.num_attention_heads = num_attention_heads
        self.num_key_value_heads = num_key_value_heads
        d_head = hidden_size // num_attention_heads
        # o_proj: [hidden_size, hidden_size]
        self.o_proj = nn.Linear(hidden_size, hidden_size, bias=False)
    
    def forward(self, x):
        return self.o_proj(x)

class MinimalLayer(nn.Module):
    def __init__(self, hidden_size, num_attention_heads, num_key_value_heads):
        super().__init__()
        self.self_attn = MinimalSelfAttention(hidden_size, num_attention_heads, num_key_value_heads)

class MinimalHFModel(nn.Module):
    def __init__(self, hidden_size, num_attention_heads, num_key_value_heads, num_hidden_layers):
        super().__init__()
        self.hidden_size = hidden_size
        self.num_attention_heads = num_attention_heads
        self.num_key_value_heads = num_key_value_heads
        self.num_hidden_layers = num_hidden_layers
        self.layers = nn.ModuleList([
            MinimalLayer(hidden_size, num_attention_heads, num_key_value_heads)
            for _ in range(num_hidden_layers)
        ])

class MinimalHFLM(nn.Module):
    def __init__(self, hidden_size, num_attention_heads, num_key_value_heads, num_hidden_layers):
        super().__init__()
        self.model = MinimalHFModel(hidden_size, num_attention_heads, num_key_value_heads, num_hidden_layers)

class MinimalConfig:
    def __init__(self, hidden_size, num_attention_heads, num_key_value_heads, num_hidden_layers):
        self.hidden_size = hidden_size
        self.num_attention_heads = num_attention_heads
        self.num_key_value_heads = num_key_value_heads
        self.num_hidden_layers = num_hidden_layers

# Set up dimensions
B = 2  # batch size
T = 5  # sequence length
hidden_size = 8
num_attention_heads = 4
num_key_value_heads = 2
num_hidden_layers = 2
d_head = hidden_size // num_attention_heads

device = torch.device('cpu')

# Create config and model
config = MinimalConfig(
    hidden_size=hidden_size,
    num_attention_heads=num_attention_heads,
    num_key_value_heads=num_key_value_heads,
    num_hidden_layers=num_hidden_layers
)

hf_lm = MinimalHFLM(
    hidden_size=hidden_size,
    num_attention_heads=num_attention_heads,
    num_key_value_heads=num_key_value_heads,
    num_hidden_layers=num_hidden_layers
)

# Create tensors
all_v = {
    L: torch.randn(B, num_key_value_heads, T, d_head)
    for L in range(num_hidden_layers)
}

attentions = tuple(
    torch.randn(B, num_attention_heads, T, T)
    for L in range(num_hidden_layers)
)

last_pos = torch.randint(0, T, (B,), dtype=torch.long)

r_dir = torch.randn(B, hidden_size)

attention_mask = torch.ones(B, T, dtype=torch.float32)
for i in range(B):
    pos = last_pos[i].item()
    if pos < T - 1:
        attention_mask[i, pos+1:] = 0.0

a_mask = torch.bernoulli(torch.full((B, T), 0.5))
b_mask = 1.0 - a_mask

ARGS = {
    'all_v': all_v,
    'attentions': attentions,
    'last_pos': last_pos,
    'r_dir': r_dir,
    'a_mask': a_mask,
    'b_mask': b_mask,
    'attention_mask': attention_mask,
    'hf_lm': hf_lm,
    'config': config,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
bitsandbytes, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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
steer_past_kv_V Ran
ran; our contract draft was wrong, not the code
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("4824148c30e8ce88")
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 6, 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 os

torch.manual_seed(0)

# Set up tiny tensors for batch_size=2, seq_len=5, num_heads=3, head_dim=4
batch_size = 2
num_heads = 3
seq_len = 5
head_dim = 4
num_layers = 2

# Create kv_cache as a list of (k, v) tuples (legacy format)
kv_cache = []
for layer in range(num_layers):
    k = torch.randn(batch_size, num_heads, seq_len, head_dim)
    v = torch.randn(batch_size, num_heads, seq_len, head_dim)
    kv_cache.append((k, v))

# a_mask and b_mask: shape (batch_size, seq_len), aligned to padded prompt length
a_mask = torch.tensor([
    [1.0, 1.0, 0.0, 0.0, 0.0],
    [1.0, 1.0, 1.0, 0.0, 0.0]
], dtype=torch.float32)

b_mask = torch.tensor([
    [0.0, 1.0, 1.0, 0.0, 0.0],
    [0.0, 0.0, 1.0, 1.0, 0.0]
], dtype=torch.float32)

# attention_mask: shape (batch_size, seq_len), zeroes out pad positions
attention_mask = torch.tensor([
    [1.0, 1.0, 1.0, 0.0, 0.0],
    [1.0, 1.0, 1.0, 1.0, 0.0]
], dtype=torch.float32)

# kv_bad_mask_by_layer: Dict[layer_idx, tensor of shape (batch_size, num_heads)]
# indicates which heads are "bad" and should be steered
kv_bad_mask_by_layer = {
    0: torch.tensor([
        [1.0, 0.0, 1.0],
        [0.0, 1.0, 0.0]
    ], dtype=torch.float32),
    1: torch.tensor([
        [1.0, 1.0, 0.0],
        [1.0, 0.0, 1.0]
    ], dtype=torch.float32)
}

# Steering coefficients
gamma_A = 0.5
gamma_B = 0.3

ARGS = {
    'kv_cache': kv_cache,
    'a_mask': a_mask,
    'b_mask': b_mask,
    'attention_mask': attention_mask,
    'kv_bad_mask_by_layer': kv_bad_mask_by_layer,
    'gamma_A': gamma_A,
    'gamma_B': gamma_B
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 6, 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
dla_steer_generate Not yet run
unverified (harvested, no recorded run)
cindy2000sh/v-steer/steering.py
code served (permissive licence) · get_code("4d665917e9acee94")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 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 11 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-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

Instruction hierarchies are a core safety assumption of language model deployment: higher priority inputs, such as system prompts, should override conflicting lower priority inputs from users or tools. Yet frontier LLMs often violate this hierarchy. We introduce V-Steer, a training-free inference time method that restores privileged influence by editing cached value vectors at prompt positions. Using direct logit attribution on the first next token prediction, V-Steer identifies heads where lower priority spans dominate privileged ones, then boosts privileged spans and suppresses conflicting lower priority spans through in-place multiplicative edits to cached V tensors. Since the method acts only on cached values, it remains compatible with fused attention backends and adds only a one time prefill overhead. Across models from 7B to 70B, this attribution guided intervention raises primary constraint accuracy from under 18% up to 92% on controlled role conflict benchmarks, and on broader instruction hierarchy evaluations substantially outperforms prompt only baselines while matching or exceeding SoTA training based methods on 3 of 4 scales of LLMs, with negligible decoding-speed overhead. The code is available at https://github.com/cindy2000sh/v-steer.

For agents

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

get_harvested_code_for_paper("2607.26228")
get_code_for_paper("2607.26228")
have("2607.26228")

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

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

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

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

Connect an agent — have() is free.