I built a Python wrapper for the OpenAI SDK that compresses text into images before sending to vision models. Basically for large contexts, images can be more token-efficient than raw text.
The approach builds on DeepSeek’s OCR compression research. Through 90+ experiments using an “Optical Needle in a Haystack” evaluation framework, I systematically optimized compression parameters across fonts, sizes, and resolutions.
Key results:
– Gemini 2.0 Flash Lite: 2.8:1 compression at 93.65% accuracy
– Qwen 2.5-VL-72B: 2.2:1 compression at 94.44% accuracy
– Optimal settings: 864x864px, 12px Atkinson Hyperlegible font (for most models)
The wrapper is a drop-in replacement for the OpenAI client – just add “compressed”: True to messages containing bulk content. I recommend keeping instructions as plain text and only compressing documents, chat history, or codebases.
Links:
– Wrapper library: https://github.com/MaxDevv/Un-LOCC-Wrapper
– Research & benchmarks: https://github.com/MaxDevv/Un-LOCC
Comments URL: https://news.ycombinator.com/item?id=45820573
Points: 1
# Comments: 0
Source: github.com