paperbot · PL 论文追踪

全部论文 待读 收藏

P2 LongCodeZip: Compress Long Context for Code Language Models

LongCodeZip:为代码语言模型压缩长上下文
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 3/10 · 论文研究代码 LLM 的长上下文压缩,属于 LLM 效率优化,而非用户核心关注的静态分析、形式化验证、浮点或贝叶斯程序分析;仅与 PL+AI 交叉及 Agentic 长上下文处理有间接关联,研究目标本身偏向提升 LLM 能力。引用 4 inbox
Yuling Shi, Yichun Qian, Hongyu Zhang, Beijun Shen, Xiaodong Gu
crossref: 2026-09-12

AI 速览

一句话:提出面向代码 LLM 的双阶段即插即用上下文压缩框架,最高达 5.6× 压缩比且不损失任务性能。

随着代码大模型需要在庞大代码库上推理,长上下文代码生成日益关键,但高 API 成本与生成延迟仍是主要瓶颈。现有通用文本剪枝方法(如 LLMLingua)忽略代码特有的结构与依赖,在编程任务上效果欠佳。本文提出 LongCodeZip,一个专为代码 LLM 设计、即插即用的压缩框架,采用双阶段策略:粗粒度压缩基于对指令的条件困惑度对函数级代码块排序,只保留最相关函数;细粒度压缩按困惑度将保留函数切分为块,并在自适应 token 预算下选出最优子集以最大化相关性。在代码补全、代码摘要与问答等任务上的评估显示,LongCodeZip 持续优于基线方法,在任务性能不下降的前提下实现最高 5.6× 的压缩比,从而助力 LLM 扩展到真实大规模代码场景。

问题
长上下文代码任务中 API 成本与生成延迟居高不下,而现有通用文本剪枝方法忽视了代码特有的结构与依赖关系,导致编程任务表现次优。
方法
采用双阶段压缩:先用基于指令条件困惑度的函数级粗粒度筛选,保留最相关函数;再按困惑度将函数切分为块,在自适应 token 预算下做细粒度最优子集选择。
评估
在代码补全、代码摘要、问答等多个任务上与基线方法对比,实现最高 5.6× 压缩比且任务性能不下降。
原文摘要(Abstract)

Code generation under long contexts is becoming increasingly critical as Large Language Models (LLMs) are required to reason over extensive information in the code-base. 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.6× 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 applications1.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9219,
  title = {LongCodeZip: Compress Long Context for Code Language Models},
  author = {Yuling Shi and Yichun Qian and Hongyu Zhang and Beijun Shen and Xiaodong Gu},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00020}
}