LongCodeZip: Compress Long Context for Code Language Models

AI-generated keywords: Code Generation Long Contexts Large Language Models Code Compression Efficiency

AI-generated Key Points

  • Authors address the need for code generation under long contexts in Large Language Models (LLMs)
  • Introduction of LongCodeZip, a code compression framework tailored for code LLMs
  • Dual-stage strategy: coarse-grained compression ranks function-level chunks based on conditional perplexity, fine-grained compression segments functions into blocks using perplexity metrics
  • LongCodeZip achieves up to a 5.6x compression ratio without compromising task performance
  • Enables LLMs to scale better in real-world large-scale code scenarios and enhances efficiency and capability of code intelligence applications
  • Provides insights into datasets used for evaluation, results on long-code completion tasks, and emphasizes the importance of refining compression techniques
Also access our AI generated: Comprehensive summary, Lay summary, Blog-like article; or ask questions about this paper to our AI assistant.

Authors: Yuling Shi, Yichun Qian, Hongyu Zhang, Beijun Shen, Xiaodong Gu

Accepted to ASE 2025. Code available at https://github.com/YerbaPage/LongCodeZip
License: CC BY 4.0

Abstract: 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.

Submitted to arXiv on 01 Oct. 2025

Ask questions about this paper to our AI assistant

You can also chat with multiple papers at once here.

AI assistant instructions?

Results of the summarizing process for the arXiv paper: 2510.00446v1

In their paper "LongCodeZip: Compress Long Context for Code Language Models," authors Yuling Shi, Yichun Qian, Hongyu Zhang, Beijun Shen, and Xiaodong Gu address the increasing need for code generation under long contexts in Large Language Models (LLMs). Recent advancements have enabled code LLMs to process extensive information in codebases. However, high API costs and generation latency remain significant challenges. To tackle these issues, the authors introduce LongCodeZip - a novel plug-and-play code compression framework tailored for code LLMs. LongCodeZip adopts a dual-stage strategy: coarse-grained compression identifies and ranks function-level chunks based on conditional perplexity with respect to instructions. It retains only the most relevant functions. Fine-grained compression further segments retained functions into blocks using perplexity metrics and selects an optimal subset within an adaptive token budget to maximize relevance. The evaluations conducted across various tasks such as code completion, summarization, and question answering demonstrate that LongCodeZip consistently outperforms baseline methods by achieving up to a 5.6x compression ratio without compromising task performance. By effectively reducing context size while preserving essential information, LongCodeZip enables LLMs to scale better in real-world large-scale code scenarios. This enhances the efficiency and capability of code intelligence applications. Additionally, the authors provide insights into datasets used for evaluating long-context code compression and present results on long-code completion tasks. They also discuss the limitations of existing methods and emphasize the importance of refining compression techniques for stricter compression ratios. Overall, offers a promising solution to address the challenges associated with processing long contexts in . Its implementation can greatly improve in tasks, especially under . With its focus on , LongCodeZip provides a valuable contribution to the field and has the potential to enhance the capabilities of code intelligence applications.
Created on 15 Jan. 2026

Assess the quality of the AI-generated content by voting

Score: 0

Why do we need votes?

Votes are used to determine whether we need to re-run our summarizing tools. If the count reaches -10, our tools can be restarted.

Similar papers summarized with our AI tools

Navigate through even more similar papers through a

tree representation

Look for similar papers (in beta version)

By clicking on the button above, our algorithm will scan all papers in our database to find the closest based on the contents of the full papers and not just on metadata. Please note that it only works for papers that we have generated summaries for and you can rerun it from time to time to get a more accurate result while our database grows.

Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.