CodeShrink: 효율적인 다중 모드 코드 이해를 위한 적응형 시각 압축
CodeShrink: Adaptive Visual Compression for Efficient Multimodal Code Understanding
소스 코드를 이미지로 표현하는 것은 멀티모달 대규모 언어 모델(MLLM)의 입력 비용을 줄이는 유망한 방법입니다. 이미지 해상도를 조정하면 시각적 토큰 비용과 콘텐츠 충실도 간의 균형을 맞출 수 있습니다. 그러나 해상도 스케일링만으로는 줄 바꿈 및 들여쓰기로 인해 생성되는 빈 영역, 그리고 현재 지시에 관련 없는 코드 영역이라는 두 가지 비효율성의 원인을 간과합니다. 또한 최적의 압축 설정은 입력, 작업 및 모델에 따라 달라지므로 고정 비율 전략을 적용하기 어렵습니다. 본 연구에서는 세 가지 구성 요소로 이루어진 적응형 시각 압축 프레임워크인 CodeShrink를 제안합니다. Blank-Free Rendering은 줄 바꿈 의존적인 레이아웃을 간결한 레이아웃과 명시적인 구조적 마커로 대체하여 레이아웃으로 인해 발생하는 토큰 수를 제거합니다. Adaptive Compression Configuration은 강화 학습을 통해 훈련된 경량 에이전트를 사용하여 입력별 설정을 예측하며, 이는 토큰 효율성과 가독성 사이의 균형을 맞춥니다. Dominant Token Selection은 지시와 코드 이미지 모두를 함께 분석하여 추론 과정에서 작업과 관련 없는 시각적 토큰을 제거합니다. CodeShrink는 코드 질문 답변, 클론 탐지 및 코드 완성 작업을 통해 평가되었습니다. CodeShrink는 시각적 토큰 사용량을 최대 71.2%까지 줄이면서 압축되지 않은 텍스트 입력과 동일하거나 더 나은 성능을 보였으며, 세 가지 작업 모두에서 기존의 텍스트 기반 및 시각 압축 방법보다 우수한 결과를 얻었습니다. 이러한 결과는 레이아웃 압축, 적응형 구성 및 지시 인식 기반 제거를 결합하면 멀티모달 코드 이해를 더욱 효율적으로 만들 수 있음을 보여줍니다. 본 연구의 코드는 https://github.com/vinsontang1/CodeShrink 에서 확인할 수 있습니다.
Rendering source code as images offers a promising way to reduce the input costs of Multimodal Large Language Models (MLLMs). Adjusting image resolution can trade visual token cost against content fidelity. However, resolution scaling alone overlooks two sources of inefficiency: blank regions created by line breaks and indentation, and code regions irrelevant to the current instruction. Moreover, the best compression setting varies across inputs, tasks, and models, limiting fixed-ratio strategies. We propose CodeShrink, an adaptive visual compression framework with three components. Blank-Free Rendering replaces whitespace-dependent layouts with compact layouts and explicit structural markers, removing layout-induced tokens. Adaptive Compression Configuration uses a lightweight agent trained with reinforcement learning to predict a per-input setting that balances token efficiency and readability. Dominant Token Selection jointly analyzes the instruction and code image to prune task-irrelevant visual tokens during inference. We evaluate CodeShrink on code question answering, clone detection, and code completion. CodeShrink reduces visual token use by up to 71.2\% while matching or exceeding uncompressed text-only inputs, and consistently outperforms text-based and visual compression baselines across all three tasks. These results show that combining layout compaction, adaptive configuration, and instruction-aware pruning can make multimodal code understanding more efficient. Our code is available at https://github.com/vinsontang1/CodeShrink.
No Analysis Report Yet
This paper hasn't been analyzed by Gemini yet.
Log in to request an AI analysis.