让单块显卡实现无限上下文的多模态大模型流式推理。
Inf-MLLM: Efficient Streaming Inference of Multimodal Large Language Models on a Single GPU
- 发现注意力模式'鞍点',动态缓存关键上下文。
- 支持400万词长文本与1小时视频对话,单卡稳定运行。
- 适合边缘设备部署,推理速度比现有方法快2倍。
多模态大语言模型(MLLMs)凭借其多模态综合能力,在GPT-4o、自动驾驶和机器人等领域广泛应用。然而,多模态输入常导致超长上下文,推理时需缓存大量先前标记的键值状态(KV cache),造成高延迟和内存消耗。这使得在边缘设备上部署流式推理极为困难,严重限制了实际应用。本文提出Inf-MLLM,一种高效的MLLM推理框架,可在单块GPU上实现无限上下文的流式推理。其核心基于对LLMs和MLLMs中注意力模式的新发现——'注意力鞍点'。借助该模式,Inf-MLLM通过动态缓存近期及相关标记,维持有限大小的KV cache。同时提出注意力偏置(attention bias),使MLLM能有效捕捉长期依赖。实验表明,Inf-MLLM可在单卡上稳定处理长达400万词的文本及一小时长视频的多轮对话。相比StreamingLLM,推理质量更优;相比H2O,提速达2倍。
原文摘要 · Abstract (English)
Multimodal Large Language Models (MLLMs) are distinguished by their multimodal comprehensive ability and widely used in many real-world applications including GPT-4o, autonomous driving and robotics. Despite their impressive performance, the multimodal inputs always incur long context. The inference under long context requires caching massive Key and Value states (KV cache) of previous tokens, which introduces high latency and excessive memory consumption. Due to this reason, it is challenging to deploy streaming inference of MLLMs on edge devices, which largely constrains the power and usage of MLLMs in real-world applications. In this paper, we introduce Inf-MLLM, an efficient inference framework for MLLMs, which enable streaming inference of MLLM on a single GPU with infinite context. Inf-MLLM is based on our key observation of the attention pattern in both LLMs and MLLMs called "attention saddles". Thanks to the newly discovered attention pattern, Inf-MLLM maintains a size-constrained KV cache by dynamically caching recent tokens and relevant tokens. Furthermore, Inf-MLLM proposes attention bias, a novel approach to enable MLLMs to capture long-term dependency. We show that Inf-MLLM enables multiple LLMs and MLLMs to achieve stable performance over 4M-token long texts and multi-round conversations with 1-hour-long videos on a single GPU. In addition, Inf-MLLM exhibits superior streaming reasoning quality than existing methods such as StreamingLLM and 2x speedup than H2O.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。