# LongCodeZip: Compress Long Context for Code Language Models

**Authors:** Yuling Shi, Yichun Qian, Hongyu Zhang, Beijun Shen, Xiaodong Gu  
**arXiv:** [2510.00446](https://arxiv.org/abs/2510.00446)  
**Date:** 2025-10-01  
**Summary page:** https://www.summarizepaper.com/en/paper/2510.00446v1/

## 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

## Summary

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.
