Do not copy and paste! Rewriting strategies for code retrieval
Not on the map. Why?
Abstract (arXiv)
Embedding-based code retrieval often 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 full Natural-Language transcription, under joint query-corpus (QC, online) and corpus-only (C, offline) augmentation, across six CoIR benchmarks, five encoders, and three rewriters spanning independent model families (Qwen, DeepSeek, Mistral). We are the first to evaluate NL-enriched PseudoCode and 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, and Delta s, embedding cosine, and show that Delta H predicts retrieval gain under QC across all three rewriter families: pooled Spearman rho = +0.436, p < 0.001 on DeepSeek+Codestral; rho = +0.593 on Codestral alone; rho = +0.356 on Qwen. This establishes Delta H as a cheap, rewriter-agnostic proxy for deciding when rewriting pays off before running retrieval. Our analysis reframes LLM rewriting as 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.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 12 of its 13 references that are in the map. First posted on arXiv 8 May 2026.
Builds on
12 of 13 references.
References · 12
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2022Text Embeddings by Weakly-Supervised Contrastive Pre-trainingcited by 1,216
- 2025Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Modelscited by 1,175
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2020Generation-Augmented Retrieval for Open-domain Question Answeringcited by 186
- 2024CoIR: A Comprehensive Benchmark for Code Information Retrieval Modelscited by 59
- 2024CodeXEmbed: A Generalist Embedding Model Family for Multiligual and Multi-task Code Retrievalcited by 33
- 2024Rewriting the Code: A Simple Method for Large Language Model Augmented Code Searchcited by 17
- 2025MoSE: Hierarchical Self-Distillation Enhances Early Layer Embeddingscited by 2
- 2025Assessing Code Understanding in LLMscited by 2
- 2025PseudoBridge: Pseudo Code as the Bridge for Better Semantic and Logic Alignment in Code Retrievalcited by 2
Built on by
Not cited yet.