arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.00746cs.SEcs.CV
收藏

视觉-语言模型能处理长上下文代码吗?对视觉压缩的实证研究

Can Vision-Language Models Handle Long-Context Code? An Empirical Study on Visual Compression

Zhejiang University(浙江大学);Hangzhou City University(杭州市大学);Shenzhou Aerospace Software Technology Company Limited(神州航天软件技术有限公司)

Jianping Zhong, Guochang Li, Chen Zhi, Junxiao Han, Zhen Qin, Xinkui Zhao, Nan Wang, Shuiguang Deng, Jianwei Yin

AI总结:

本文提出LongCodeOCR,通过视觉压缩替代文本压缩,提升长上下文代码任务的性能与效率,同时揭示了视觉压缩在全局依赖支持与保真度之间的权衡。

摘要:

大型语言模型(LLMs)由于窗口限制在处理长上下文代码时存在困难。现有的文本代码压缩方法通过选择性过滤来缓解这一问题,但往往破坏依赖闭合,导致语义碎片化。为了解决这一问题,我们引入了LongCodeOCR,一种视觉压缩框架,将代码转换为压缩的二维图像序列,供视觉-语言模型(VLMs)使用。通过保留全局视图,这种方法避免了过滤中固有的依赖断裂问题。我们系统地在四个基准测试中评估LongCodeOCR与最先进的LongCodeZip。我们的结果表明,视觉代码压缩在需要全局理解的任务中是一个可行的替代方案。在可比的压缩比(约1.7倍)下,LongCodeOCR在长模块摘要任务中将CompScore提高了36.85分超过LongCodeZip。在100万token上下文长度下使用Glyph(一种专门的90亿参数VLM),LongCodeOCR的准确性高于LongCodeZip,同时压缩率高约4倍。此外,与LongCodeZip相比,LongCodeOCR大幅减少了压缩阶段的开销(在100万token时将延迟从约4.3小时减少到约1分钟)。最后,我们的结果揭示了一个基本的覆盖范围—保真度权衡:视觉代码压缩保留更广泛的上下文覆盖以支持全局依赖,但面临在精确性关键任务上的保真度瓶颈;相比之下,文本代码压缩保持符号级精度,但牺牲了结构覆盖。

英文摘要:

Large Language Models (LLMs) struggle with long-context code due to window limitations. Existing textual code compression methods mitigate this via selective filtering but often disrupt dependency closure, causing semantic fragmentation. To address this, we introduce LongCodeOCR, a visual compression framework that renders code into compressed two-dimensional image sequences for Vision-Language Models (VLMs). By preserving a global view, this approach avoids the dependency breakage inherent in filtering. We systematically evaluate LongCodeOCR against the state-of-the-art LongCodeZip across four benchmarks spanning code summarization, code question answering, and code completion. Our results demonstrate that visual code compression serves as a viable alternative for tasks requiring global understanding. At comparable compression ratios ($\sim$1.7$\times$), LongCodeOCR improves CompScore on Long Module Summarization by 36.85 points over LongCodeZip. At a 1M-token context length with Glyph (a specialized 9B VLM), LongCodeOCR maintains higher accuracy than LongCodeZip while operating at about 4$\times$ higher compression. Moreover, compared with LongCodeZip, LongCodeOCR drastically reduces compression-stage overhead (reducing latency from $\sim$4.3 hours to $\sim$1 minute at 1M tokens). Finally, our results characterize a fundamental coverage--fidelity trade-off: visual code compression retains broader context coverage to support global dependencies, yet faces fidelity bottlenecks on exactness-critical tasks; by contrast, textual code compression preserves symbol-level precision while sacrificing structural coverage.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑