跳到主要內容
AI 武林
影片高階EN2.3 萬 次觀看

Build A Reasoning Model From Scratch 2: Loading a Base Model, Text Generation, and KV Caching

來源 Sebastian Raschka人物 Sebastian Raschka

看影片(在新分頁開啟原站)連到 YouTube・Sebastian Raschka

摘要

本影片是「從零建構推理模型」系列的第二集,由 Sebastian Raschka 示範如何載入預訓練的 Qwen3 模型並設定文字生成。內容涵蓋了分詞器使用、推理模式下的批次處理、以及透過 KV 快取與模型編譯大幅提升生成速度的實作細節。

This video demonstrates loading a pre-trained Qwen3 model, setting up text generation, and optimizing inference speed using KV caching and model compilation.

摘要、重點與章節標題由語言模型整理,細節(誰說的、數字、先後)可能有誤;要引用請以原始內容為準。

重點

  • 示範如何載入 Qwen3 模型並設定分詞器與推理模式。
  • 解釋 KV 快取原理並實作以加速重複計算的文字生成。
  • 比較 CPU、GPU 與 MPS 效能,並介紹 PyTorch 模型編譯技術。

章節

依話題轉折切分,標題由 AI 產生

  1. 00:00Introduction and reasoning model demo
  2. 01:55How to work through the book
  3. 05:00Chapter 2 overview
  4. 08:25Checking PyTorch and hardware support
  5. 10:26Apple silicon and MPS caveats
  6. 15:00Cloud GPU options
  7. 16:08Tokens and tokenization
  8. 18:20Qwen3 and the Reasoning From Scratch package
  9. 23:05Encoding and decoding text
  10. 26:24Downloading weights and selecting a device
  11. 31:01Loading the pretrained Qwen3 model
  12. 34:32How LLMs generate text
  13. 36:47Input tensors and batch dimensions
  14. 41:48Running the model in inference mode
  15. 44:11Logits and next-token predictions
  16. 49:21Greedy decoding with argmax
  17. 52:28Building a streaming text generator
  18. 1:01:28Generating text and handling end-of-sequence tokens
  19. 1:06:00Benchmarking text generation
  20. 1:14:34How KV caching works
  21. 1:17:22Adding KV caching and measuring the speedup
  22. 1:24:31Model compilation with torch.compile
  23. 1:30:33Combining compilation with KV caching
  24. 1:32:53Comparing CPU and GPU performance
  25. 1:35:32Recap and next steps

提到的工具與公司

適合誰看

希望實作大型語言模型文字生成、最佳化推理效能或學習 PyTorch 基礎的開發者。

摘要依據

講者
Sebastian Raschka
依據
人工字幕

為什麼排在這裡

人氣
0.54
新鮮
0.72

在主題頁與搜尋結果裡,名次由相關、人氣、新鮮三個分數決定;這一頁沒有搜尋的關鍵字,所以沒有相關分數。排序怎麼算

這個來源最近的內容

Sebastian Raschka 的所有內容

摘要由 AI 根據原文產生,可能有誤;完整內容請看原站。看影片(在新分頁開啟原站)