SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2408.09121 · ICML · 2025

Selective Prompt Anchoring for Code Generation

Tianyi Zhang, Yuan Tian

arXiv · PDF · Open in the Atlas

Code that ran

7 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; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 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/2408.09121.json · badge: /api/ran/2408.09121.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
magic-YuanTian/Selective-Prompt-Anchoring canonical (classifier label)
classifier basis: census
4 ran · 3 no recorded run
magic-yuantian/selective-prompt-anchoring canonical (classifier label)
classifier basis: classifier_2025
3 ran · 1 no recorded run
FunctionStatusWhere it lives
create_masked_attention Ran
ran; our contract draft was wrong, not the code
magic-yuantian/selective-prompt-anchoring/code/spa.py
code served (permissive licence) · get_code("37eb35f878deabb1")
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) and returned Tensor, ndim 2, dtype family int, shape (1, 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)

class SimpleTokenizer:
    """Minimal tokenizer that supports encode and decode operations."""
    
    def __init__(self):
        self.vocab = {
            0: "[PAD]",
            1: "hello",
            2: "world",
            3: "foo",
            4: "bar",
            5: "test",
            6: "string",
        }
        self.reverse_vocab = {v: k for k, v in self.vocab.items()}
    
    def encode(self, text, add_special_tokens=False):
        """Encode text to token ids."""
        words = text.lower().split()
        token_ids = []
        for word in words:
            if word in self.reverse_vocab:
                token_ids.append(self.reverse_vocab[word])
            else:
                token_ids.append(1)
        return token_ids
    
    def decode(self, token_ids):
        """Decode token ids to text."""
        tokens = []
        for token_id in token_ids:
            if isinstance(token_id, int):
                tokens.append(self.vocab.get(token_id, "[UNK]"))
            else:
                tokens.append(self.vocab.get(int(token_id), "[UNK]"))
        return " ".join(tokens)

tokenizer = SimpleTokenizer()

input_ids = torch.tensor([[1, 2, 3, 4]])

target_strings = ["world"]

ARGS = {
    "input_ids": input_ids,
    "target_strings": target_strings,
    "tokenizer": tokenizer,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 (1, 4) — shape (1, 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
divide_tasks Ran
ran; our contract draft was wrong, not the code
magic-YuanTian/Selective-Prompt-Anchoring/obsolete/obsolete/anchor_evaluation.py
code served (permissive licence) · get_code("8e08f76d757c9320")
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. 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)

# Analyze the function: it takes tasks (any iterable/sequence) and num_groups (int)
# It divides tasks into roughly equal parts using list slicing
# The function only uses len(tasks), divmod, and list slicing - no methods called on tasks

# Create a simple list of tasks (can be anything - strings, ints, objects, etc.)
tasks = ['task_0', 'task_1', 'task_2', 'task_3', 'task_4', 'task_5', 'task_6']

# Number of groups to divide into
num_groups = 3

ARGS = {
    'tasks': tasks,
    'num_groups': num_groups
}
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 — a list 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
find_last_python_function Ran
ran; our contract draft was wrong, not the code
magic-YuanTian/Selective-Prompt-Anchoring/obsolete/obsolete/weighted_utils/weighted_text_utils.py
code served (permissive licence) · get_code("48f4dd62f3915251")
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 re

def find_last_python_function(code: str) -> str:
    function_starts = [match.start() for match in re.finditer('\\ndef\\s', code)]
    if function_starts:
        last_function_start = function_starts[-1]
        last_function_text = code[last_function_start:]
        previous_code = code[:last_function_start]
        return (previous_code, last_function_text)
    else:
        raise ValueError('No function definitions found in the provided code.')

# Create a code string with multiple function definitions
code_with_functions = """
def first_function(x):
    return x + 1

def second_function(y):
    return y * 2

def last_function(z):
    return z - 1
"""

ARGS = {
    "code": code_with_functions
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
format_spa_input Ran
ran; our contract draft was wrong, not the code
magic-yuantian/selective-prompt-anchoring/code/spa.py
code served (permissive licence) · get_code("bdebcb7bf7024120")
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) 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 re

# Test case 1: String input with anchors
input_str = "The quick brown fox jumps over the lazy dog. The fox is clever."
anchors = ["fox", "dog"]
mask_token = "[MASK]"

ARGS = {
    "input": input_str,
    "anchors": anchors,
    "mask_token": mask_token,
    "whole_word_only": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — 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
get_gpus_max_memory Ran
ran; our contract draft was wrong, not the code
magic-YuanTian/Selective-Prompt-Anchoring/obsolete/obsolete/weighted_utils/weighted_text_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from tianyi-lab/moe-embedding, is pointer only (licence: NONE) · get_code("aecadcaa2ac48b1b")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from tianyi-lab/moe-embedding, 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.

load_tasks_from_jsonl Ran
ran; our contract draft was wrong, not the code
magic-YuanTian/Selective-Prompt-Anchoring/obsolete/obsolete/anchor_evaluation.py
code served (permissive licence) · get_code("39c4708ddb6031ae")
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 json
import tempfile
import os

# Create a temporary JSONL file with sample task data
temp_dir = tempfile.mkdtemp()
jsonl_file = os.path.join(temp_dir, "tasks.jsonl")

# Write some sample tasks to the JSONL file
sample_tasks = [
    {"id": 1, "task": "task_a", "data": [1, 2, 3]},
    {"id": 2, "task": "task_b", "data": [4, 5, 6]},
    {"id": 3, "task": "task_c", "data": [7, 8, 9]},
]

with open(jsonl_file, 'w') as f:
    for task in sample_tasks:
        f.write(json.dumps(task) + '\n')

ARGS = {
    "jsonl_file": jsonl_file,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
preprocess_anchors Ran
ran; our contract draft was wrong, not the code
magic-yuantian/selective-prompt-anchoring/code/spa.py
code served (permissive licence) · get_code("8a1f0cd88536eecf")
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) 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

ARGS = {
    "anchors": ["hello", "world", "test", "a", "", " ", "longer_anchor"]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
SPALogitsProcessor Not yet run
unverified (harvested, no recorded run)
magic-yuantian/selective-prompt-anchoring/code/spa.py
code served (permissive licence) · get_code("2c88019eca86410e")
How it ran

no invocation recorded.

get_dataset Not yet run
unverified (harvested, no recorded run)
magic-YuanTian/Selective-Prompt-Anchoring/obsolete/obsolete/SPA_tune.py
code served (permissive licence) · get_code("556744211a325503")
How it ran

no invocation recorded.

get_gpus_max_memory Not yet run
unverified (harvested, no recorded run)
magic-YuanTian/Selective-Prompt-Anchoring/obsolete/obsolete/weighted_utils/weighted_text_model_load.py
code served (permissive licence) · get_code("d9977f2786c4b8d9")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
magic-YuanTian/Selective-Prompt-Anchoring/obsolete/obsolete/weighted_utils/weighted_text_utils.py
code served (permissive licence) · get_code("f32275a7d9ecf730")
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 10 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 9 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
get_gpus_max_memory 4 other papers
1 dated earlier, 3 later
2402.09906 (2024-02)
Generative Representational Instruction Tuning
2410.10814 (2024-10)
Your Mixture-of-Experts LLM Is Secretly an Embedding Model For Free
2025.findings-acl.1384 (2025 (year only))
Accelerating Adaptive Retrieval Augmented Generation via Instruction-Driven Representation Reduction of Retrieval Overlaps
and 1 more not named here

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

Recent advances in large language models (LLMs) have transformed software development by automatically generating code from natural language. Yet challenges remain in generating fully correct code that aligns with user intent. Our study reveals that LLMs tend to pay less attention to user prompts as more code tokens are generated. We hypothesize that this attention dilution issue is an important reason for code generation errors. To mitigate this issue, we propose Selective Prompt Anchoring (SPA) to guide code LLMs to pay more attention to user intent when generating code. We evaluate SPA using six base LLMs across six benchmarks. Our results demonstrate that SPA enhances Pass@1 by up to 12.9%, consistently outperforming SOTA methods in all settings. Our code is available at https://github.com/magic-YuanTian/Selective-Prompt-Anchoring.

For agents

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

get_harvested_code_for_paper("2408.09121")
get_code_for_paper("2408.09121")
have("2408.09121")

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

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

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

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

Connect an agent — have() is free.