SAM Decoding: Speculative Decoding via Suffix Automaton

Yuxuan Hu, Ke Wang, Xiaokang Zhang, Fanjin Zhang, Cuiping Li +2 more
11/16/2024
50 citations
cs.CLcs.AI

Official code: hyx1999/SAM-Decoding (53 stars, Python, last commit 2025-02-13).

Abstract

Speculative decoding (SD) has been demonstrated as an effective technique for lossless LLM inference acceleration. Retrieval-based SD methods, one kind of model-free method, have yielded promising speedup, but they often rely on incomplete retrieval resources, inefficient retrieval methods, and are constrained to certain domains.

Show full abstract

This paper presents a novel retrieval-based speculative decoding method that adapts suffix automaton (SAM) for efficient and accurate draft generation by utilizing common text corpus and dynamic text sequence. Unlike existing $n$-gram matching methods, SAM-Decoding finds the exact longest suffix match, achieving an average time complexity of O(1) per generation step of SAM update and suffix retrieval. It can also integrate with existing methods, adaptively selecting a draft generation strategy based on match length to generalize to broader domains. Extensive experiments on Spec-Bench show that our method is $18\%+$ faster than other retrieval-based SD methods. Additionally, when combined with advanced EAGLE-2, it provides an additional speedup of $3.28\%$ -- $11.13\%$ across various-sized LLM backbones. Our code is available at our \href{https://github.com/hyx1999/SAM-Decoding}{repository}.

View on arXivView PDF

Code Implementations(1)

Official Implementation of SAM-Decoding: Speculative Decoding via Suffix Automaton

532Python, ShellOct 23, 20241 years ago
speculative-decoding

Similar Papers

Cite this paper

@article{hu2024decoding,
  title  = {SAM Decoding: Speculative Decoding via Suffix Automaton},
  author = {Yuxuan Hu and Ke Wang and Xiaokang Zhang and Fanjin Zhang and Cuiping Li and Hong Chen and Jing Zhang},
  year   = {2024},
  eprint = {2411.10666},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2411.10666v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2411.10666.svg)](https://codeofpaper.com/paper/2411.10666)

Discussion