ChatPaper.aiChatPaper

LongCodeZip: 코드 언어 모델을 위한 긴 컨텍스트 압축

LongCodeZip: Compress Long Context for Code Language Models

October 1, 2025
저자: Yuling Shi, Yichun Qian, Hongyu Zhang, Beijun Shen, Xiaodong Gu
cs.AI

초록

긴 컨텍스트 하에서의 코드 생성은 대형 언어 모델(LLMs)이 코드베이스 내 광범위한 정보를 추론해야 하는 요구가 증가함에 따라 점점 더 중요해지고 있습니다. 최근의 발전으로 코드 LLMs가 긴 입력을 처리할 수 있게 되었지만, 높은 API 비용과 생성 지연 시간은 여전히 주요 병목 현상으로 남아 있습니다. LLMLingua와 같은 기존의 컨텍스트 정제 기술은 일반 텍스트에 대해 유망한 결과를 달성하지만, 코드 특유의 구조와 의존성을 간과하여 프로그래밍 작업에서 최적의 성능을 내지 못합니다. 본 논문에서는 코드 LLMs를 위해 특별히 설계된 새로운 플러그 앤 플레이 코드 압축 프레임워크인 LongCodeZip을 제안합니다. LongCodeZip은 이중 단계 전략을 사용합니다: (1) 거친 단계의 압축으로, 조건부 perplexity를 사용하여 명령어에 대한 함수 수준의 청크를 식별하고 순위를 매겨 가장 관련성이 높은 함수만을 유지합니다; (2) 세밀한 단계의 압축으로, 유지된 함수를 perplexity를 기반으로 블록으로 분할하고 적응형 토큰 예산 하에서 최적의 부분 집합을 선택하여 관련성을 극대화합니다. 코드 완성, 요약, 질문 응답을 포함한 다양한 작업에 대한 평가에서 LongCodeZip은 기준 방법들을 일관되게 능가하며, 작업 성능을 저하시키지 않고 최대 5.6배의 압축 비율을 달성합니다. LongCodeZip은 컨텍스트 크기를 효과적으로 줄이면서 필수 정보를 보존함으로써, LLMs가 실제 대규모 코드 시나리오에 더 잘 확장할 수 있도록 하여 코드 인텔리전스 애플리케이션의 효율성과 능력을 향상시킵니다.
English
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.
PDF1027October 3, 2025