Research Papers 论文研究 4h ago Updated 28m ago 更新于 28分钟前 49

Accelerating LLM Inference via Vector Index Based Output Embeddings 通过向量索引输出嵌入加速LLM推理

Large output embedding matrices in LLMs create a memory bandwidth bottleneck during autoregressive decoding, particularly for compact models with large multilingual vocabularies The authors reformulate the output projection and top-k token selection as a maximum inner product search problem, replacing dense vocabulary projection with an HNSW-based vector index The method retrieves only a small candidate set of high-scoring tokens and integrates into existing pipelines by scattering retrieved log 大型输出嵌入矩阵在自回归解码时造成显著内存带宽瓶颈,尤其影响紧凑LLM的多语言词汇表场景 将输出投影+top-k token选择重构为最大内积搜索,用HNSW向量索引替代密集词汇投影 输出头仅检索少量高分token候选集,通过散射logits到稀疏全词汇张量集成到现有解码管道 在CPU推理上,Gemma 3、Llama 3.2、Qwen 3模型输出投影显著加速,Gemma 3 270M端到端batch-size-one解码吞吐量提升高达82% 近似检索在延迟敏感的小批量解码场景下是密集输出投影的实用替代方案,AlpacaEval评估保持生成质量

65
Hot 热度
75
Quality 质量
70
Impact 影响力

Analysis 深度分析

TL;DR

  • Large output embedding matrices in LLMs create a memory bandwidth bottleneck during autoregressive decoding, particularly for compact models with large multilingual vocabularies
  • The authors reformulate the output projection and top-k token selection as a maximum inner product search problem, replacing dense vocabulary projection with an HNSW-based vector index
  • The method retrieves only a small candidate set of high-scoring tokens and integrates into existing pipelines by scattering retrieved logits into a sparse full-vocabulary tensor
  • On CPU inference with Gemma 3, Llama 3.2, and Qwen 3 models, the approach improves batch-size-one decoding throughput by up to 82% (Gemma 3 270M) while preserving generation quality on AlpacaEval
  • Approximate retrieval via vector indexes is demonstrated as a practical alternative to dense output projections in latency-sensitive small-batch decoding scenarios

Why It Matters

This work addresses a critical bottleneck in LLM inference that becomes increasingly relevant as models deploy on edge devices and CPU-only environments where memory bandwidth is a limiting factor. By reframing token generation as an approximate nearest neighbor search problem, it opens a new optimization pathway that could influence how inference engines are designed for resource-constrained deployments.

Technical Details

  • The core innovation replaces the standard dense output projection (matrix multiplication against the full vocabulary embedding matrix) with an HNSW (Hierarchical Navigable Small World) vector index built over token embeddings
  • The output head performs maximum inner product search to retrieve a small candidate set of high-scoring tokens, then scatters the retrieved logits back into a sparse full-vocabulary tensor for standard top-k selection
  • Evaluated on CPU inference across three model families: Gemma 3 (270M parameter variant), Llama 3.2, and Qwen 3, demonstrating the approach generalizes across architectures
  • Generation quality was validated using AlpacaEval, confirming that the approximation introduced by vector index retrieval does not meaningfully degrade output quality
  • The method is designed for seamless integration into existing decoding pipelines without requiring architectural modifications to the base model

Industry Insight

  • As the industry pushes toward smaller, more efficient models for edge and on-device deployment, memory-bandwidth optimization techniques like this will become increasingly valuable compared to compute-centric optimizations
  • The HNSW-based approach could be adopted by inference frameworks (vLLM, TensorRT-LLM, etc.) as a configurable optimization for CPU inference paths, particularly for multilingual models with vocabularies exceeding 100K tokens
  • This work suggests a broader trend: treating LLM output projection as a retrieval problem rather than a linear algebra operation, which could inspire similar approximate methods for other expensive operations in the decoding pipeline

TL;DR

  • 大型输出嵌入矩阵在自回归解码时造成显著内存带宽瓶颈,尤其影响紧凑LLM的多语言词汇表场景
  • 将输出投影+top-k token选择重构为最大内积搜索,用HNSW向量索引替代密集词汇投影
  • 输出头仅检索少量高分token候选集,通过散射logits到稀疏全词汇张量集成到现有解码管道
  • 在CPU推理上,Gemma 3、Llama 3.2、Qwen 3模型输出投影显著加速,Gemma 3 270M端到端batch-size-one解码吞吐量提升高达82%
  • 近似检索在延迟敏感的小批量解码场景下是密集输出投影的实用替代方案,AlpacaEval评估保持生成质量

为什么值得看

本文针对LLM推理中的关键性能瓶颈——输出嵌入矩阵的内存带宽问题,提出了一种基于向量索引的优化方案,对边缘设备和小批量推理场景具有重要参考价值。研究团队来自Lincoln AI Lab,Sepp Hochreiter是深度学习领域的知名学者,该工作为LLM部署优化提供了新的技术路径。

技术解析

  • 核心问题:自回归解码过程中,输出投影层需要将隐藏状态与大型词汇表嵌入矩阵做矩阵乘法,对于多语言词汇表(如32K+ tokens)的紧凑模型,这成为内存带宽瓶颈
  • 技术方案:将传统的密集输出投影+top-k选择重构为最大内积搜索(MIPS)问题,使用HNSW(Hierarchical Navigable Small World)向量索引加速token检索
  • 实现细节:输出头仅检索少量高分token候选集,然后将检索到的logits散射(scatter)到稀疏的全词汇张量中,可无缝集成到现有解码管道
  • 实验设置:在CPU推理环境下测试Gemma 3、Llama 3.2、Qwen 3系列模型,使用batch-size-one场景评估端到端解码吞吐量
  • 评估指标:吞吐量提升(Gemma 3 270M达82%)和生成质量(AlpacaEval评估),证明近似检索不会显著损害输出质量

行业启示

  • 向量检索技术(如HNSW)正在从推荐系统、RAG等领域向LLM推理优化渗透,近似最近邻搜索将成为边缘部署的重要技术方向
  • 小批量/单样本推理(batch-size-one)是实际部署中最常见的场景,针对该场景的优化比大batch吞吐优化更具实用价值
  • 紧凑模型(如270M参数)的多语言扩展面临输出层瓶颈,未来模型设计需考虑词汇表大小与推理效率的平衡

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

LLM 大模型 Inference 推理 Embedding Model 嵌入模型 Research 科学研究