Code generation under long contexts is becoming increasingly critical as Large Language Models (LLMs) are required to reason over extensive information in the codebase. While recent advances enable code LLMs to process long inputs, high API costs and generation latency remain substantial bottlenecks. Existing context pruning techniques, such as LLMLingua, achieve promising results for general text but overlook code-specific structures and dependencies, leading to suboptimal performance in programming tasks. In this paper, we propose LongCodeZip, a novel plug-and-play code compression framework designed specifically for code LLMs. LongCodeZip employs a dual-stage strategy: (1) coarse-grained compression, which identifies and ranks function-level chunks using conditional perplexity with respect to the instruction, retaining only the most relevant functions; and (2) fine-grained compression, which segments retained functions into blocks based on perplexity and selects an optimal subset under an adaptive token budget to maximize relevance. Evaluations across multiple tasks, including code completion, summarization, and question answering, show that LongCodeZip consistently outperforms baseline methods, achieving up to a 5.6x compression ratio without degrading task performance. By effectively reducing context size while preserving essential information, LongCodeZip enables LLMs to better scale to real-world, large-scale code scenarios, advancing the efficiency and capability of code intelligence applications.
Autoencoding-Free Context Compression for LLMs via Contextual Semantic Anchors
School of Computer Science and Engineering, Northeastern University, Shenyang, China(东北大学计算机科学与工程学院,中国沈阳);NiuTrans Research, Shenyang, China(沈阳NiuTrans研究院,中国);Kunming University of Science and Technology, Kunming, China(昆明理工大学,中国昆明)
Position IDs Matter: An Enhanced Position Layout for Efficient Context Compression in Large Language Models
NLP Lab, School of Computer Science and Engineering, Northeastern University, Shenyang, China(东北大学计算机科学与工程学院自然语言处理实验室);NiuTrans Research, Shenyang, China(NiuTrans研究院)
Perception Compressor: A Training-Free Prompt Compression Framework in Long Context Scenarios
Shenzhen International Graduate School, Tsinghua University(清华大学深圳国际研究生院);Pengcheng Laboratory(鹏城实验室);Ant Group(蚂蚁集团);School of Artificial Intelligence, Sun Yat-sen University(中山大学人工智能学院)
From Context to EDUs: Faithful and Structured Context Compression via Elementary Discourse Unit Decomposition
DeepLang AI;Department of Computer Science and Technology, Tsinghua University(计算机科学与技术系,清华大学);Beijing University of Posts and Telecommunications(北京邮电大学);Beijing Jiaotong University(北京交通大学)
Concept than Document: Context Compression via AMR-based Conceptual Entropy
University of Southern Queensland(南方昆士兰大学);University of Technology Sydney(技术悉尼大学);The Hong Kong Polytechnic University(香港理工大学);Wuhan University of Technology(武汉理工大学);National University of Singapore(新加坡国立大学);The Education University of Hong Kong(香港教育大学)
ChunkKV: Semantic-Preserving KV Cache Compression for Efficient Long-Context LLM Inference
The Hong Kong University of Science and Technology (Guangzhou)(香港科学与技术大学(广州));CSE, The Hong Kong University of Science and Technology(香港科学与技术大学计算机科学与工程系);Guangzhou HKUST Fok Ying Tung Research Institute(广州HKUST福 Ying Tung研究 institute);Terminus Technologies
Selecting What Matters: Semantic Compression-Guided Selective Pooling for Long-Context Embeddings
State Key Laboratory for Novel Software Technology, Nanjing University(南京大学计算机软件新技术国家重点实验室);National University of Singapore(新加坡国立大学);Nanjing University of Posts and Telecommunications(南京邮电大学)
QUITO-X: A New Perspective on Context Compression from the Information Bottleneck Theory
State Key Laboratory of AI Safety, ICT, CAS(人工智能安全国家重点实验室);University of Chinese Academy of Sciences(中国科学院大学);Peking University(北京大学);Hong Kong University of Science and Technology (Guangzhou)(香港科技大学(广州))
AdaComp: Extractive Context Compression with Adaptive Predictor for Retrieval-Augmented Large Language Models
Beijing Advanced Innovation Center for Future Blockchain and Privacy Computing(北京未来区块链与隐私计算先进创新中心);School of Artificial Intelligence, Beihang University(北航人工智能学院);Beijing Academy of Blockchain and Edge Computing(北京区块链与边缘计算研究院);Institute of Computing Technology, Chinese Academy of Sciences(中国科学院计算技术研究所)