# 李宏毅_生成式導論 2024_第16講:可以加速所有語言模型生成速度的神奇外掛 — Speculative Decoding ###### tags: `Hung-yi Lee` `NTU` `生成式導論 2024` [課程撥放清單](https://www.youtube.com/watch?v=AVIKFXLCPY8&list=PLJV_el3uVTsPz6CTopeRp2L2t4aL_KgiI) ## 第16講:可以加速所有語言模型生成速度的神奇外掛 — Speculative Decoding [課程連結](https://www.youtube.com/watch?v=MAbGgsWKrg8&list=PLJV_el3uVTsPz6CTopeRp2L2t4aL_KgiI&index=17) ### 覺得現在語言模型還不夠是嗎?  這邊課程談的是最新的技術,Speculative Decoding,這可以用來加速模型生成的速度。 這個技術本身跟模型完全無關,任何模型都可以使用,是一個外掛性質的技術。 ### Speculative Decoding  [參考論文_Fast Inference from Transformers via Speculative Decoding](https://arxiv.org/abs/2211.17192) [參考論文_Accelerating Large Language Model Decoding with Speculative Sampling](https://arxiv.org/abs/2302.01318) Speculative本身有猜測、投機的意思。 大致的概念就是,如果我們可以有個預言家預判接下來會說什麼,那是不是就可以讓這個預言家先猜測,根據現在給定的條件所輸出的下一個token會是什麼,如果可以先猜,那就可以把下下一個先生成出來。 ### Speculative Decoding  上面簡報給出一個比較直觀的說明,如果說預言家已經可以預測出下兩個token的話,那語言模型就可以直接吐出三個token,因為一、二已經知道了,它可以直接給出第三個。 ### Speculative Decoding  如果說預言家真的那麼神的話,那也不用主要模型來輸出了,都給預言家玩就好了,所以,預言家也是會犯錯的。 ### Speculative Decoding  假設,預言家的第二個token是預測錯誤的,模型根據這兩個token生成第三個,我們只要嚐試比較模型輸出的前兩個跟預言家預測是不是正確的就可以知道預言家有沒有唬爛了。 ### Speculative Decoding  即使預言家的預言都是錯的,整體結果來看還是跟原本的一樣。 ### Speculative Decoding  對預言家的最基本要求就是,快,快,快,還要快,然後偶彌犯錯沒有關係。 這種情況下,也許Non-autoregressive Model很適合,因為它可以同時生成一批輸出,特性就是快,狠,不準。非常符合預言家的資格。 甚至我們還可以對模型做壓縮,透過不同的方法將模型變成小模型,變成小模型的優點就是推論速度快,缺點就是效能不好。不過沒關係,仍然是符合預言家的資格。 ### Speculative Decoding  [參考論文_Inference with Reference: Lossless Acceleration of Large Language Models](https://arxiv.org/abs/2304.04487) 預言家不一定要是一個語言模型,也可以是搜尋引擎。 ### Speculative Decoding:多個預言家  [參考論文_SpecInfer: Accelerating Generative Large Language Model Serving with Tree-based Speculative Inference and Verification](https://arxiv.org/abs/2305.09781) 預言家不會限制只有1個,江湖上愛喇叭的人特別多,可以多個。
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.