Research
CodeShrink Renders Code as Images and Cuts Visual Tokens 71.2% While Beating Text-Only Input
Rendering source code as images can lower MLLM input costs, but resolution scaling alone wastes tokens on whitespace from indentation and line breaks and on code irrelevant to the instruction, and the best compression setting shifts per input, task, and model. CodeShrink combines blank-free rendering with explicit structural markers, an RL-trained lightweight agent that predicts a per-input compression setting, and instruction-aware pruning of task-irrelevant visual tokens at inference. Across code QA, clone detection, and code completion it cuts visual token use up to 71.2% while matching or exceeding uncompressed text-only inputs; code is released.
↳ Follow the thread