CODEPROMPTZIP: Code-specific Prompt Compression for Retrieval-Augmented Generation in Coding Tasks with LMs
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Retrieval-Augmented Generation (RAG) enhances coding tasks by incorporating retrieved code examples into prompts. However, lengthy prompts, often exceeding tens of thousands of tokens, introduce challenges related to limited context windows of language models (LMs) and high computational costs. Existing prompt compression techniques focus on natural language, lacking tailored solutions for code. To address the gap, we propose CodePromptZip, a framework that compresses code examples before integrating into RAG workflows. Our framework employs a type-aware, priority-driven strategy to construct training samples for training code compression model. By using program analysis, we identify token types (e.g., Identifier) and perform ablation analysis to rank their removal priorities based on their impact on task performance. We then train a small LM as the compressor on these samples, enabling flexible compression conditioned on specified ratios while minimizing performance degradation. Specially, the compressor is augmented with a copy mechanism, allowing tokens to be directly copied from the original code snippets. Evaluation results show that CodePromptZip surpasses SOTA entropy-based and distillation-based baselines, improving by 23.4%, 28.7%, and 8.7% over the best baseline for Assertion Generation, Bugs2Fix, and Code Suggestion, respectively.
Key facts. Cited by 2 papers in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 17 of its 30 references that are in the map. First posted on arXiv 19 Feb 2025.
Builds on
17 of 30 references.
References · 17
- 2023GPT-4 Technical Reportcited by 18,132
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2017Get To The Point: Summarization with Pointer-Generator Networkscited by 1,281
- 2022Atlas: Few-shot Learning with Retrieval Augmented Language Modelscited by 940
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2023LongLLMLingua: Accelerating and Enhancing LLMs in Long Context Scenarios via Prompt Compressioncited by 443
- 2023Learning to Compress Prompts with Gist Tokenscited by 379
- 2023Adapting Language Models to Compress Contextscited by 350
5 more
- 2024LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compressioncited by 343
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 181
- 2023Unlocking Context Constraints of LLMs: Enhancing Context Efficiency of LLMs with Self-Information-Based Content Filteringcited by 62
- 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Codecited by 62
- 2023Discrete Prompt Compression with Reinforcement Learningcited by 42
Built on by
Citing papers per year: 2025: 1; 2026: 1.
2 papers.
Similar, not cited
Close in wording, no citation either way
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
- 2025Understanding and Improving Information Preservation in Prompt Compression for LLMs
- 2024Evaluating the Effectiveness and Efficiency of Demonstration Retrievers in RAG for Coding Tasks
- 2024PERC: Plan-As-Query Example Retrieval for Underrepresented Code Generation
- 2025Less Is More: Elevating RAG via Performance-Driven Context Compression
- 2024Style-Compress: An LLM-Based Prompt Compression Framework Considering Task-Specific Styles
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities