LLM-based Source Code Compression via Thresholded Symbol Ranking
Summary
A new study introduces LLM-based compressors that enhance source code compression by employing two novel symbol-ranking variants, bounding predictions to the top-$T$ ranks ($T=1$ or $63$). This approach addresses the storage demands of large-scale software archives like Software Heritage, where general-purpose compressors often fail to exploit source code's unique regularities. Unlike prior LLM-based methods that suffer throughput degradation from arbitrarily growing predicted ranks, this $T$-bounded scheme stores out-of-threshold symbols as exceptions, compressing them jointly. A large-scale evaluation across 30 LLMs, including general-domain, code-specialized, and quantized models, demonstrated significant improvements. The new method achieved up to 37% relative compression improvement and 40% faster throughput compared to previous LLM-based compressors. It also delivered up to 82% relative compression gain over general-purpose compressors like zstd and bzip2, albeit at a lower speed, establishing a new trade-off point. These gains are more pronounced on source code than natural language, highlighting LLMs' ability to capture specific source code regularities.
Key takeaway
For software archive managers or ML engineers optimizing storage for large codebases, you should evaluate LLM-based compression with $T$-bounded symbol ranking. This method offers up to 82% relative compression gain over general-purpose tools like zstd, significantly reducing storage demands. While it operates at a lower speed, its superior compression ratio, especially with code-specialized LLMs, presents a compelling new trade-off point for your data management strategies. Consider piloting this approach for critical archives.
Key insights
Bounding LLM symbol predictions to top-$T$ ranks significantly improves source code compression ratio and throughput.
Principles
- Source code regularities are better captured by LLMs.
- Bounding symbol ranks enhances LLM compression efficiency.
Method
Deploy LLM-based compressors using top-$T$ rank bounding ($T=1$ or $63$), compressing out-of-threshold symbols as exceptions jointly.
In practice
- Apply $T$-bounded LLM compression to software archives.
- Prioritize code-specialized LLMs for compression tasks.
Topics
- LLM Compression
- Source Code Compression
- Symbol Ranking
- Lossless Data Compression
- Software Archives
- Code-specialized LLMs
Best for: Research Scientist, AI Engineer, AI Scientist, Machine Learning Engineer, NLP Engineer
Related on AIssential
See Counsel's argued verdicts on the open AI decisions leaders are weighing →
Editorial summary, takeaway, and curation by AIssential. Original article published by Computation and Language.