Do not copy and paste! Rewriting strategies for code retrieval
Summary
This research paper investigates text rewriting strategies for code retrieval, finding that full natural language rewriting offers the greatest performance gains. It introduces entropy-based diagnostics to help determine when costly LLM rewrites are beneficial.
View Cached Full Text
Cached at: 05/13/26, 12:15 PM
Paper page - Do not copy and paste! Rewriting strategies for code retrieval
Source: https://huggingface.co/papers/2605.08299
Abstract
Research investigates how different text rewriting strategies impact code retrieval performance, identifying that full natural language rewriting provides the greatest improvements while proposing entropy-based diagnostics to determine when such costly rewrites are beneficial.
Embedding-based code retrievaloften suffers when encoders overfit to surface syntax. Prior work mitigates this by using LLMs to rephrase queries and corpora into a normalized style, but leaves two questions open: how much representational shift helps, and when is the per-query LLM call justified? We study a hierarchy of three rewriting strategies:stylistic rephrasing,NL-enriched PseudoCode, and fullNatural-Language transcription, under joint query-corpus (QC, online) and corpus-only (C, offline) augmentation, across sixCoIR benchmarks, five encoders, and three rewriters spanning independent model families (Qwen, DeepSeek, Mistral). We are the first to evaluateNL-enriched PseudoCodeand snippet-level Natural Language as direct retrieval representations, rather than as transient intermediates. Full NL rewriting with QC yields the largest gains (+0.51 absolute NDCG@10 on CT-Contest for MoSE-18), while corpus-only rewriting degrades retrieval in 56 of 90 configurations, about 62%. We introduce two diagnostics,Delta H,token entropy, andDelta s,embedding cosine, and show thatDelta Hpredictsretrieval gainunder QC across all threerewriter families: pooled Spearman rho = +0.436, p < 0.001 on DeepSeek+Codestral; rho = +0.593 on Codestral alone; rho = +0.356 on Qwen. This establishesDelta Has a cheap, rewriter-agnostic proxy for deciding when rewriting pays off before running retrieval. Our analysis reframesLLM rewritingas a cost-benefit decision: it is most effective as a remediation layer for lightweight encoders on code-dominant queries, with diminishing returns for strong encoders or NL-heavy queries.
View arXiv pageView PDFAdd to collection
Get this paper in your agent:
hf papers read 2605\.08299
Don’t have the latest CLI?curl \-LsSf https://hf\.co/cli/install\.sh \| bash
Models citing this paper0
No model linking this paper
Cite arxiv.org/abs/2605.08299 in a model README.md to link it from this page.
Datasets citing this paper0
No dataset linking this paper
Cite arxiv.org/abs/2605.08299 in a dataset README.md to link it from this page.
Spaces citing this paper0
No Space linking this paper
Cite arxiv.org/abs/2605.08299 in a Space README.md to link it from this page.
Collections including this paper0
No Collection including this paper
Add this paper to acollectionto link it from this page.
Similar Articles
Be Kind, Rewrite: Benign Projections via Rewriting Defend Against LLM Data Poisoning Attacks
This paper introduces open-book benign rewriting (OBBR) as a proactive defense against backdoor attacks on LLMs, showing it neutralizes harmful content by projecting to benign prompts, and improves safety by 51% over state-of-the-art defenses.
Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
This paper introduces AlgoREval, a benchmark of 599 problems covering 77 classical algorithms across 14 domains, 7 languages, and 4 graph-input representations, to measure LLMs' ability to reproduce well-known algorithms as 'parametric code retrieval' rather than true synthesis. Across 15 models (7B–34B), accuracy varies widely by language and input format, and the authors caution against deploying AI-generated algorithmic code without systematic validation.
Text-Preserving Lossy Text Compression: A Study of Strategic Deletion and LLM Reconstruction
This paper systematically benchmarks various deletion strategies (e.g., frequency-guided, entropy-based) for lossy text compression where LLMs reconstruct the original text, showing that simple methods like word-frequency deletion remain competitive across retention rates.
@AhmedSQRD: Synthetic rewrites are now standard to improve data quality and when data is limited. But how much compute should you s…
A thread presenting research that fits scaling laws to determine how much compute to invest in synthetic rewrites for improving data quality, and whether a model trained on rewrites can surpass the rewriting model itself.
@dylan_works_: Wrote up something fun I’ve been poking at: when LLM agents repeatedly rewrite their own experiences into textual “less…
This research blog post demonstrates that repeatedly rewriting LLM agent experiences into textual 'lessons' often degrades performance rather than improving it. The author finds that episodic memory retention performs better than abstract consolidation across various benchmarks like ARC-AGI and ALFWorld.