Do not copy and paste! Rewriting strategies for code retrieval
- URL: http://arxiv.org/abs/2605.08299v1
- Date: Fri, 08 May 2026 11:31:26 GMT
- Title: Do not copy and paste! Rewriting strategies for code retrieval
- Abstract summary: We study a hierarchy of three rewriting strategies: stylistic rephrasing, NL-enriched PseudoCode, and full Natural-Language transcription.<n>We are the first to evaluate NL-enriched PseudoCode and snippet-level Natural Language as direct retrieval representations, rather than as transient intermediates.<n>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.
- Score: 0.7710436567988378
- License: http://creativecommons.org/licenses/by/4.0/
- Abstract: 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.
Related papers
- What the Reranker Sees: Multi-Aspect Page Annotation for Long-Document Multimodal Question Answering [21.941823782270557]
Trident is a visual-question-answering system with a visual caption, section path, entity tags, multi-axis concept hits, and a text snippet.<n>On two long-document datasets, the annotation+rerank protocol substantially improves retrieval F1 across five datasets.<n>The best Trident configuration is the strongest downstream QA pipeline in our evaluation.
arXiv Detail & Related papers (2026-08-14T19:29:42Z) - Ripple-Pivot Search: Active Parallel Decoding for Diffusion Large Language Models [66.32132912853372]
Diffusion Large Language Models (dLLMs) have emerged as a competitive alternative to autoregressive language models.<n>We propose Ripple-Pivot Search (RPS), a training-free decoding method that seeks mid-entropy positions as promising candidate pivots.<n>RPS achieves 4-10$times$ wall-clock speedup over the standard decoder while preserving generation quality, and improves accuracy over the previous lookahead baseline by up to 5.49%.
arXiv Detail & Related papers (2026-08-12T07:32:29Z) - CodeSentinel: A Three-Layer Defense Against Indirect Prompt Injection in Code Contexts [9.504326240833267]
Code large language models increasingly retrieve external code context from repositories, documentation, issue threads, and coding-agent environments.<n>We propose CodeSentinel, a three-layer inference-time sanitizer.<n>It uses Tree-sitter to extract high-risk model-facing CST nodes, then combines syntax-guided pre-filtering, CST-guided Dynamic Min-K% scoring, and node perturbation analysis to detect adversarial and natural-looking semantic triggers.<n>CodeSentinel achieves 0.80 average node-level F1, outperforming CodeGarrison, DePA, and KillBadCode.
arXiv Detail & Related papers (2026-06-17T16:12:50Z) - CoHyDE: Iterative Co-Training of LLM Rewriter & Dense Encoder for Tool Retrieval [0.3823356975862005]
CoHyDE trains the dense encoder and the rewriter as a single co-evolving system.<n>On a 10k tool subset of the ToolBench catalog, three rounds of CoHyDE improve over the strongest single-component baseline by +2.5 pp NDCG@5 on standard queries.<n>Using either component in isolation fails to match CoHyDE on both well-formed and vague queries, with losses of up to -8 pp on vague queries.
arXiv Detail & Related papers (2026-05-28T02:41:30Z) - Beyond Retrieval: A Multitask Benchmark and Model for Code Search [21.20978098597112]
textscCoREB is built from counterfactually rewritten LiveCodeBench problems in five programming languages.<n>We benchmark eleven embedding models and five rerankers across three tasks: text-to-code, code-to-text, and code-to-code.<n>textscCoREB-Reranker is the first to achieve consistent gains across all three tasks.
arXiv Detail & Related papers (2026-05-06T08:05:17Z) - NERFIFY: A Multi-Agent Framework for Turning NeRF Papers into Code [49.610331036334316]
We introduce NERFIFY, a framework that reliably converts NeRF research papers into trainable Nerfstudio plugins.<n>Code, data and implementations will be publicly released.
arXiv Detail & Related papers (2026-02-28T20:57:32Z) - Are Hypervectors Enough? Single-Call LLM Reasoning over Knowledge Graphs [13.99794289273847]
We propose PathHD, a lightweight KG reasoning framework that replaces neural path scoring with hyperdimensional computing.<n>PathHD encodes relation paths into block-diagonal GHRR hypervectors, ranks candidates with blockwise cosine similarity and Top-K pruning, and then performs a one-shot adjudication.<n>On WebQSP, CWQ, and the GrailQA split, PathHD (i) attains comparable or better Hits@1 than strong neural baselines while using one LLM call per query.
arXiv Detail & Related papers (2025-12-10T07:06:52Z) - ARCS: Agentic Retrieval-Augmented Code Synthesis with Iterative Refinement [1.980982378865332]
ARCS operates through a budgeted synthesize-execute-repair loop over a frozen model.<n>It retrieves relevant code context before generation, proposes candidates, executes them against tests, and repairs based on execution feedback.<n>On a LANL scientific corpus, it improves CodeBLEU by +0.115 over baseline RAG.
arXiv Detail & Related papers (2025-04-29T05:15:52Z) - Memorize or Generalize? Evaluating LLM Code Generation with Code Rewriting [54.48306552577881]
We argue that large language models (LLMs) are mostly doing memorization (i.e., replicating or reusing large parts of their training data) versus generalization.<n>Existing evaluations largely proxy neglecting surface/structural similarity, thereby conflating benign reuse of repeated code with harmful recall and memorization task correctness.<n>We propose Memorization Risk Index (MRI), a normalized score that combines two signals: (i) how similar the model's answer for the rewritten task is to the original ground-truth solution, and (ii) how much performance drops from the original task to its rewritten counterpart.
arXiv Detail & Related papers (2025-03-04T05:39:24Z) - Let the Code LLM Edit Itself When You Edit the Code [50.46536185784169]
underlinetextbfPositional textbfIntegrity textbfEncoding (PIE)<n>PIE reduces computational overhead by over 85% compared to the standard full recomputation approach.<n>Results demonstrate that PIE reduces computational overhead by over 85% compared to the standard full recomputation approach.
arXiv Detail & Related papers (2024-07-03T14:34:03Z) - Rewriting the Code: A Simple Method for Large Language Model Augmented Code Search [7.822427053078387]
Generation-Augmented Retrieval (GAR) framework generates exemplar code snippets to augment queries.
We propose a simple yet effective method that additionally Rewrites the Code (ReCo) within the for style normalization.
Code Style Similarity is the first metric tailored to quantify stylistic similarities in code.
arXiv Detail & Related papers (2024-01-09T12:12:50Z) - Noise-Robust Dense Retrieval via Contrastive Alignment Post Training [89.29256833403167]
Contrastive Alignment POst Training (CAPOT) is a highly efficient finetuning method that improves model robustness without requiring index regeneration.
CAPOT enables robust retrieval by freezing the document encoder while the query encoder learns to align noisy queries with their unaltered root.
We evaluate CAPOT noisy variants of MSMARCO, Natural Questions, and Trivia QA passage retrieval, finding CAPOT has a similar impact as data augmentation with none of its overhead.
arXiv Detail & Related papers (2023-04-06T22:16:53Z) - CoSQA: 20,000+ Web Queries for Code Search and Question Answering [63.92224685262063]
CoSQA dataset includes 20,604 labels for pairs of natural language queries and codes.
We introduce a contrastive learning method dubbed CoCLR to enhance query-code matching.
We show that evaluated on CodeXGLUE with the same CodeBERT model, training on CoSQA improves the accuracy of code question answering by 5.1%.
arXiv Detail & Related papers (2021-05-27T15:37:21Z) - FastLR: Non-Autoregressive Lipreading Model with Integrate-and-Fire [74.04394069262108]
We propose FastLR, a non-autoregressive (NAR) lipreading model which generates all target tokens simultaneously.
FastLR achieves the speedup up to 10.97$times$ compared with state-of-the-art lipreading model.
arXiv Detail & Related papers (2020-08-06T08:28:56Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.