影片高階EN2.3 萬 次觀看
Build A Reasoning Model From Scratch 2: Loading a Base Model, Text Generation, and KV Caching
看影片(在新分頁開啟原站)連到 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 產生
- 00:00Introduction and reasoning model demo
- 01:55How to work through the book
- 05:00Chapter 2 overview
- 08:25Checking PyTorch and hardware support
- 10:26Apple silicon and MPS caveats
- 15:00Cloud GPU options
- 16:08Tokens and tokenization
- 18:20Qwen3 and the Reasoning From Scratch package
- 23:05Encoding and decoding text
- 26:24Downloading weights and selecting a device
- 31:01Loading the pretrained Qwen3 model
- 34:32How LLMs generate text
- 36:47Input tensors and batch dimensions
- 41:48Running the model in inference mode
- 44:11Logits and next-token predictions
- 49:21Greedy decoding with argmax
- 52:28Building a streaming text generator
- 1:01:28Generating text and handling end-of-sequence tokens
- 1:06:00Benchmarking text generation
- 1:14:34How KV caching works
- 1:17:22Adding KV caching and measuring the speedup
- 1:24:31Model compilation with torch.compile
- 1:30:33Combining compilation with KV caching
- 1:32:53Comparing CPU and GPU performance
- 1:35:32Recap and next steps
提到的工具與公司
- PyTorch
- Qwen3
- Chainlit
- JupyterLab
- MPS
適合誰看
希望實作大型語言模型文字生成、最佳化推理效能或學習 PyTorch 基礎的開發者。
摘要依據
- 講者
- Sebastian Raschka
- 依據
- 人工字幕
為什麼排在這裡
- 人氣
- 0.54
- 新鮮
- 0.72
在主題頁與搜尋結果裡,名次由相關、人氣、新鮮三個分數決定;這一頁沒有搜尋的關鍵字,所以沒有相關分數。排序怎麼算
相關內容
- Building Reasoning Models from the Ground Up: A Full Video Course文章 ・ Sebastian Raschka(部落格) ・
- 加快語言模型生成速度 (2/2):KV Cache影片 ・ Hung-yi Lee ・ 39 分鐘 ・
- Build A Reasoning Model From Scratch 1: Motivation & Code Setup影片 ・ Sebastian Raschka ・ 43 分鐘 ・
- 到底什么是KV Cache,为啥不是QKV Cache,一个动画彻底搞懂!影片 ・ 轩辕的编程宇宙 ・ 13 分鐘 ・
- Understanding and Implementing Qwen3 From Scratch文章 ・ Sebastian Raschka(部落格) ・
- Qwen3.8-27B & How to Serve it Fast影片 ・ Sam Witteveen ・ 18 分鐘 ・
這個來源最近的內容
摘要由 AI 根據原文產生,可能有誤;完整內容請看原站。看影片(在新分頁開啟原站)
