arXiv:2510.17800cs.CVcs.CL2025-10ACL被引 49

用图像压缩长文本,让模型处理百万级上下文更高效

Glyph: Scaling Context Windows via Visual-Text Compression

  • 将长文本转为图像,通过视觉模型压缩输入
  • 实现3-4倍令牌压缩,精度接近Qwen3-8B
  • 适合文档理解、代码分析等长文本任务

大语言模型(LLMs)在文档理解、代码分析和多步推理等任务中越来越依赖长上下文建模。然而,将上下文窗口扩展到百万级令牌会带来巨大的计算与内存开销,限制了长上下文LLMs的实际应用。本文提出一种视觉上下文扩展的新思路——不延长令牌序列,而是将长文本渲染为图像,并由视觉语言模型(VLMs)处理。该方法显著压缩文本输入,同时保留语义信息。我们进一步设计基于LLM的遗传搜索算法,以寻找平衡准确率与压缩率的最优图像渲染配置。实验表明,该方法实现了3-4倍的令牌压缩率,在多个长上下文基准测试上精度接近Qwen3-8B;预填充和解码速度提升约4倍,微调训练速度提升约2倍。极端压缩下,一个128K上下文的VLM可处理100万令牌级别的文本任务。此外,生成的图像文本数据也适用于真实世界的多模态任务,如文档理解。代码与模型已开源:https://github.com/thu-coai/Glyph。

原文摘要 · Abstract (English)

Large language models (LLMs) increasingly rely on long-context modeling for tasks such as document understanding, code analysis, and multi-step reasoning. However, scaling context windows to the million-token level brings prohibitive computational and memory costs, limiting the practicality of long-context LLMs. In this work, we take a different perspective-visual context scaling-to tackle this challenge. Instead of extending token-based sequences, we propose Glyph, a framework that renders long texts into images and processes them with vision-language models (VLMs). This approach substantially compresses textual input while preserving semantic information, and we further design an LLM-driven genetic search to identify optimal visual rendering configurations for balancing accuracy and compression. Through extensive experiments, we demonstrate that our method achieves 3-4x token compression while maintaining accuracy comparable to leading LLMs such as Qwen3-8B on various long-context benchmarks. This compression also leads to around 4x faster prefilling and decoding, and approximately 2x faster SFT training. Furthermore, under extreme compression, a 128K-context VLM could scale to handle 1M-token-level text tasks. In addition, the rendered text data benefits real-world multimodal tasks, such as document understanding. Our code and model are released at https://github.com/thu-coai/Glyph.

长文本处理视觉编码上下文压缩多模态

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。