atlas

Research map / Large language models / Language, safety and interpretability

Selective Prompt Anchoring for Code Generation

ICML 2025 · Large language models › Language, safety and interpretability · approach: Controlled text generation · 1 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes Selective Prompt Anchoring (SPA), a training-free logit-arithmetic method that amplifies the influence of user-prompt tokens by combining logits from original and mask-replaced prompts, to counter attention dilution in code generation.

Problem

LLMs pay progressively less attention to the user prompt as they generate more code tokens (attention dilution), which is linked to code generation errors.

Approach

Approximates the effect of scaling a prompt segment's semantic influence by a first-order (Taylor) approximation: augmented logits = w * f(original) + (1-w) * f(prompt with anchored tokens masked), requiring no weight updates and no attention-head editing.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
apply SPA to code generationsix code LLMs · HumanEval, HumanEval+, MBPP, MBPP+, BigCodeBench, LiveCodeBenchPass@1: up to 12.9%Helped
include source code in the anchored text (ablation)SPA with natural-language anchoring · HumanEvalPass@1 improvement (%): 5.48 -> 4.87Hurt
include test cases in the anchored text (ablation)SPA with natural-language anchoring · HumanEvalPass@1 improvement (%): 5.48 -> 5.11Hurt
include source code and test cases in the anchored text (ablation)SPA with natural-language anchoring · HumanEvalPass@1 improvement (%): 5.48 -> 4.76Hurt
anchor human-labeled important tokens instead of natural language (ablation)SPA · HumanEvalPass@1 improvement (%): 5.48 -> 3.66Hurt
apply SPA across prompt-length subsetssix code LLMs · HumanEval, short promptsPass@1 improvement (%): 1.1% averageMixed
apply SPA across prompt-length subsetssix code LLMs · HumanEval, medium promptsPass@1 improvement (%): 3.2% averageMixed
apply SPA across prompt-length subsetssix code LLMs · HumanEval, long promptsPass@1 improvement (%): 11.7% averageHelped
increase anchoring strength beyond its optimum (ablation)SPA · code generationPass@1Hurt
use SPA for GSM8KLlama-3.1-Instruct-8B · GSM8Kperformance: + 1.10%Helped
use SPA for MMLULlama-3.1-Instruct-8B · MMLUperformance: + 0%No clear effect
use SPA for TruthfulQA TruthfulnessLlama-3.1-Instruct-8B · TruthfulQA (Truth.)performance: + 3.14%Helped

Surprising findings

Limitations

Experimental setup

Datasets: HumanEval MBPP HumanEval+ MBPP+ BigCodeBench LiveCodeBench

Benchmarks: HumanEval HumanEval+ MBPP MBPP+ BigCodeBench LiveCodeBench HumanEval-X TruthfulQA GSM8K MMLU BoolQ

Metrics: Pass@1 Pass@10 latency (tokens/sec)

Baselines: PASTA Self-Debugging Self-Planning ReAct Self-Edit Base model greedy decoding

Builds on: PASTA anchoring effect contrastive decoding

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy