Popular LLM Models 學習筆記(考試溫習版)
0. 30 秒總複習(考前最後掃描)
【一句話】這一課把「生成式 AI 的家族」拆成三塊:熱門 LLM 產品、
預測式 AI vs 生成式 AI 的原理對照、以及 LLM 與 RAG 的取捨。
三條主線
① Popular LLM → 有哪些產品、各自屬於誰
② Predictive AI vs Generative AI → 一個「預測」、一個「創造」
③ LLM vs RAG → 靠訓練記憶 vs 靠外部檢索
生成式模型的四大類
GAN 生成器 vs 判別器,零和對抗
Diffusion 加噪 → 去噪,DDPM/DDIM/SDE
VAE 學潛在表徵(latent)
AR 自迴歸,用前面的值預測下一個(LLM 就是這一類)
課程示範的程式
LLM.ipynb distilgpt2 文字生成
RAG.ipynb distilbert 檢索 + distilgpt2 生成
Predictive AI.ipynb LinearRegression 預測房價
Gen AI.ipynb Stable Diffusion 1.5 生成圖片
| 你會用到的東西 | 一句話記法 |
|---|---|
| Generative AI | 創造新內容(文字/圖/音/影片/程式碼) |
| Predictive AI | 預測未來結果(分類、回歸、分數) |
| GAN | Generator 造假、Discriminator 辨真,零和對抗 |
| Diffusion | 先加噪、再學著去噪;取樣慢但品質高 |
| DDPM / DDIM | DDPM 是機率式去噪;DDIM 是加速取樣器 |
| AIGC | AI 完全生成的內容(對比 PGC/UGC) |
| RAG | 先把文件向量化存進向量庫,回答時才檢索 |
max_length |
⚠️ 總長度(prompt + 生成),不是「生成幾個 token」 |
max_new_tokens |
✅ 正確的「最多再生成幾個 token」 |
temperature |
越大越隨機;0.7 一般、1.5 已經開始胡言亂語 |
guidance_scale |
擴散模型的「聽話程度」,SD 預設 7.5 |
num_inference_steps |
去噪步數,SD 預設 20;步數↑品質↑時間↑ |
| all-MiniLM-L6-v2 | 本課 RAG 章節舉例的嵌入模型(384 維) |
| distilbert-base-uncased | Lab RAG.ipynb 實際用的嵌入模型(768 維) |
1. 課程地圖:三條主線
課程把整份內容切成三個主題,這三個主題就是本課的骨架:
| # | 主題 | 白話 | 本筆記章節 |
|---|---|---|---|
| ① | Popular LLM | 市面上有哪些對話式生成式 AI、分別是誰做的 | §3–§15 |
| ② | Predictive AI vs Generative AI | 一個負責「預測」、一個負責「創造」,原理與用途完全不同 | §16–§28 |
| ③ | Large Language Model (LLM) vs Retrieval-Augmented Generation (RAG) | 知識是「記在模型裡」還是「查外部資料」 | §29–§30 |
1.1 為什麼要學「產品」而不只學「原理」
課程逐一介紹 ChatGPT、Gemini、Copilot、Llama、Grok、Perplexity、 Kimi、通義、DeepSeek、第三方聚合 App 與 AI 偵測器。原因是:
- 這一課的考題幾乎都出自「誰做的/屬於哪一類」——例如 Perplexity 是「AI 搜尋引擎」而非通用聊天機器人、 Copilot 綁在 Microsoft 生態、Llama 是 Meta 的開源權重模型。
- 課程後半(Lesson 6 的 Hugging Face、Lesson 7 的本機 LLM)會直接用到「開源權重模型」這個概念, 而 Llama 與 DeepSeek 就是開源路線的代表。
1.2 全課的邏輯順序
生成式 AI 是什麼(§2)
↓
有哪些產品(§3–§15) ← 第 ① 條主線
↓
原理對照:預測 vs 生成(§16–§28) ← 第 ② 條主線
↓
LLM 記憶 vs RAG 檢索(§29–§30) ← 第 ③ 條主線
↓
四支 Lab 程式(§32)
考點:三個 bullet 就是三個主題名稱,考題常直接問「本課三大主題為何」。 注意第二個主題是 Predictive AI vs Generative AI(不是「AI vs ML」),第三個是 LLM vs RAG(不是「LLM vs GAN」)。
2. 什麼是生成式 AI(Generative Artificial Intelligence)
課程給了本課對生成式 AI 的第一個定義,原文重點:
Generative AI refers to the field of artificial intelligence (AI) that focuses on creating models or systems capable of generating new content, such as images, text, music, or even videos. These models use machine learning techniques, particularly deep learning, to learn patterns and structures from existing data and then generate new content that is similar to the training data.
2.1 拆解成四個要素
| 要素 | 說法 | 說明 |
|---|---|---|
| 產出 | images, text, music, videos | 多模態:不只文字 |
| 方法 | machine learning,特別是 deep learning | 不是規則式系統 |
| 學習對象 | patterns and structures from existing data | 一定要有訓練資料 |
| 結果特性 | similar to the training data | 產出「像」訓練資料,不是憑空創造 |
2.2 「Generative」與「Predictive」的關鍵分野
課程在這裡先埋了伏筆,§16 才正式展開對照:
| Predictive AI | Generative AI | |
|---|---|---|
| 動作 | 預測一個值/類別 | 產生一份新內容 |
| 例子 | 明天會不會下雨 | 寫一首關於下雨的詩 |
| 輸出空間 | 有限(標籤或數值) | 開放(任意文字/像素) |
2.3 課程給了兩次定義,措辭不同
課程兩處各給了一次生成式 AI 的定義:
- 其中一處強調「creating models or systems capable of generating new content」——能力導向。
- 另一處強調「create new content … by learning patterns from existing data, Unlike predictive AI, which forecasts outcomes」——對比導向。
考點:生成式 AI 的定義一定會出現 "new content" 與 "patterns from existing data" 這兩個關鍵詞。 看到選項寫「生成式 AI 會預測未來結果」就是錯的——那是 Predictive AI。
3. 熱門 LLM 總覽:六個對話式生成式 AI
課程列出的清單(括號內是官方定位):
| 產品 | 說明 | 開發者 | 定位 |
|---|---|---|---|
| ChatGPT | Generative Pre-trained Transformer by Open AI | OpenAI | 通用對話(§4–§5) |
| Gemini / Bard | by Google | 通用對話(§6) | |
| Copilot | by Microsoft | Microsoft | 綁定 Microsoft 生態(§8) |
| Llama / Meta | by Meta / Facebook | Meta | 開源權重模型(§9) |
| Grok | by Elon Musk | xAI | 綁定 X(Twitter)平台(§10) |
| Perplexity | AI Search Engine | Perplexity AI | 搜尋引擎,不是純聊天(§11) |
3.1 一個關鍵問題:「與 Google 搜尋有何不同?」
課程最後一行寫著:
• What is the different with Google Search?
這是一條考題等級的對比,答案是五層差異:
| 比較項 | 傳統 Google 搜尋 | 對話式 LLM(如 ChatGPT) |
|---|---|---|
| 回傳什麼 | 連結清單,你自己點進去看 | 直接寫一段答案 |
| 誰做整合 | 你(使用者)做閱讀與彙整 | 模型做彙整 |
| 資料時效 | 即時抓取網頁 | 受限於訓練截止日(cutoff date) |
| 出錯方式 | 找不到就沒有結果 | 會一本正經地編造(hallucination) |
| 可追溯性 | 每個結果都有來源網址 | 通常沒有(→ 這正是 RAG 要解決的,見 §29) |
考點:Perplexity 之所以被標成 "AI Search Engine",就是因為它把上面兩欄合起來—— 用 LLM 生成答案,同時附上來源引用。考題很愛問「哪一個是 AI 搜尋引擎」。
3.2 六個產品的三個分類維度
把上表重新切一次,會得到三個好記的分類:
- 封閉原始碼:ChatGPT、Gemini、Copilot、Grok、Perplexity
- 開放權重(可下載到自己電腦跑):Llama(→ 這也是 Lesson 7「Local LLM」的主角)
- 搜尋導向:Perplexity
4. ChatGPT:介面與用途
課程示範 ChatGPT 的介面與用途:
| 主題 | 重點 |
|---|---|
| ChatGPT 主畫面 | 產品主視覺與外部圖片來源 |
| 舊版主畫面(Main screen) | 早期的對話介面 |
| 新版主畫面(New ChatGPT) | 改版後的介面 |
| 寫履歷示範(Writing a resume) | 用 ChatGPT 產出一份結構化長文件 |
4.1 為什麼要示範「寫履歷」
因為那是最能體現 LLM 價值的文字生成任務:輸入是一段不完整的需求, 輸出是一份結構化的長文件。課程以此說明「生成式 AI 直接產出成品,而不是給你搜尋結果」。
4.2 介面兩個版本的教育意義
課程對比「舊版主畫面」與「New ChatGPT 主畫面」。要讀出的訊息是:
- 同一個產品會一直改版:模型版本、介面、功能都會變。
- 但「輸入 prompt → 取得文字回覆」這個互動模型沒有變。
- 考試考的是互動模型,不是某個版本的按鈕位置。
4.3 ChatGPT 這個名字本身就是定義
ChatGPT = Chat + GPT,而 GPT = Generative Pre-trained Transformer。
| 縮寫 | 全稱 | 意思 |
|---|---|---|
| G | Generative | 生成式:產出新內容 |
| P | Pre-trained | 預訓練:先在大規模語料上學通用語言能力 |
| T | Transformer | 用的架構是 Transformer |
考點:GPT 三個字母的展開是必考題。特別注意「Pre-trained」指的是先預訓練、後微調的兩階段流程, 而不是「已經訓練完成」的意思。
5. ChatGPT 的智慧從哪來:RLHF、獎勵模型與 PPO
ChatGPT is an example of a Large Language Model (LLM))。
這是 §4–§5 裡唯一有實質文字內容的一段,也是全課最常考的原理題。
5.1 核心敘述
原文:
The company OpenAI trained ChatGPT using reinforcement learning. By Reinforcement Learning from Human Feedback (RLHF), using the same methods as InstructGPT, but with slight differences in the data collection setup.
並補上兩個對照的定義:
| 名詞 | 定義 |
|---|---|
| Supervised / unsupervised machine learning | algorithms making predictions about data |
| Reinforcement learning | train an agent to operate in an environment through interaction in order to maximize reward |
5.2 課程給出的三階段流程
課程把 RLHF 拆成三步,這是必背的骨幹:
① Supervised Fine-Tuning(SFT,監督式微調)
人類 AI 訓練員「扮演對話雙方」寫出示範對話
→ 用這些示範資料微調初始模型
↓
② Reward Model(獎勵模型)
收集「比較資料」(comparison data)——讓訓練員對多個回覆排名
→ 訓練出一個能替回覆打分的獎勵模型
↓
③ PPO(Proximal Policy Optimization,近端策略優化)
用獎勵模型當訊號,以 PPO 微調語言模型
→ 「the process was repeated several times」(這個流程重複數次)
5.3 三個階段各自在解決什麼問題
| 階段 | 輸入 | 輸出 | 為什麼需要 |
|---|---|---|---|
| ① SFT | 人類寫的示範對話 | 一個「會照著回答」的模型 | 預訓練模型只會接龍,不會聽指令 |
| ② 獎勵模型 | 人類的排序(A 比 B 好) | 一個自動打分器 | 人類無法對每一次生成即時打分,需要可規模化的替代品 |
| ③ PPO | 獎勵模型的分數 | 更符合人類偏好的模型 | 把「分數」轉成權重更新 |
考點:RLHF 的三階段順序是 SFT → Reward Model → PPO。 常見錯答是把 Reward Model 放在 SFT 之前,或把 PPO 說成「訓練獎勵模型的方法」—— PPO 是拿獎勵模型當訊號去訓練語言模型,兩者角色不同。
5.4 為什麼是「比較」而不是「打分」
課程特別寫 "comparison data was collected"。原因是:
- 要人類給出絕對分數(例如 87 分)不一致:同一個人前後兩次可能給不同分。
- 要人類排序(這個比那個好)一致得多。
- 所以獎勵模型學的是「哪個回覆比較好」這個相對判斷。
5.5 LLM 的定義
課程給出本課對 LLM 的正式定義:
A large language model (LLM) is a type of artificial intelligence (AI) algorithm that uses deep learning techniques and massively large data sets to understand, summarize, generate and predict new content.
拆成三個關鍵:
| 關鍵 | 用詞 | 說明 |
|---|---|---|
| 方法 | deep learning | 深度學習,不是統計規則 |
| 資料 | massively large data sets | 「Large」的第一層意義:資料大 |
| 能力 | understand/summarize/generate/predict | 四個動詞就是四類任務 |
並以一句話收尾:
ChatGPT is an example of a Large Language Model (LLM).
考點:LLM 定義裡的四個動詞(understand、summarize、generate、predict)常被當成選項干擾源。 「Large」在這一課指資料量與參數量都大;到了 Lesson 3 會再展開成「資料大 + 參數大」兩層。
5.6 本機實測:把「預訓練模型不會聽指令」親眼看到
四支 Lab 裡,LLM/LLM.ipynb 用的就是沒有經過 RLHF 的原始預訓練模型
(distilgpt2,GPT-2 的蒸餾小模型)。它的行為正好可以驗證 §5.3 的說法——
它只會「接龍」,不會「回答」:
# LLM/LLM.ipynb 的核心(已移除 ipywidgets 互動層)
import os, sys
sys.path.insert(0, "_shim") # 見附錄 B:繞過本機 torchaudio 的 CUDA 版本問題
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("distilgpt2")
mdl = AutoModelForCausalLM.from_pretrained("distilgpt2")
mdl.config.pad_token_id = mdl.config.eos_token_id # 修正:distilgpt2 沒有 pad token
enc = tok("Write a story about a curious robot", return_tensors="pt")
out = mdl.generate(**enc, max_length=50, do_sample=True,
temperature=0.7, top_k=50,
pad_token_id=mdl.config.pad_token_id)
print(tok.decode(out[0], skip_special_tokens=True))
本機實測輸出(Python 3.11.15/torch 2.14.1+cu132/transformers 5.17.0/RTX 4090):
torch 2.14.1+cu132 | cuda True
gpu NVIDIA GeForce RTX 4090
load distilgpt2: 15.15 s
n_params = 81.9 M
pad_token_id -> 50256
=== temperature=0.7 (0.18 s) ===
prompt tokens = 7 | 實際生成 = 10 tokens
Write a story about a curious robot, a robot with a very advanced sense of humor
三個可以直接寫進考卷的觀察:
distilgpt2只有 81.9 M 參數——和「Large」Language Model 的「大」形成強烈對比, 也解釋了為什麼它的輸出品質這麼差(選它是因為不需要任何 API token、可在 Colab 免費跑)。- 它沒有回答指令,只是接龍:示範的 prompt 是 "Write a story about a curious robot", 模型的續寫是「…, a robot with a very advanced sense of humor」——它把指令當成句子的一部分, 而不是當成「請你寫一個故事」的要求。這正是沒有經過 RLHF 的預訓練模型的典型行為。
max_length=50是「總長度」:prompt 佔 7 個 token,所以最多只能再生成 43 個; 這次在 10 個 token 就遇到 EOS 停下來。這個參數是本課最大的陷阱,§19 會完整展開。
再拉高 temperature 到 1.5,可以親眼看到「越大越隨機」變成「越大越崩壞」:
=== temperature=1.5 (0.36 s) ===
prompt tokens = 7 | 實際生成 = 40 tokens
Write a story about a curious robot found in their abandoned basement where she is looking
at a baby boy's heart. Photo Credit: Wendytale - All images can be saved via the Web
輸出開始出現與 prompt 無關的網頁殘留文字("Photo Credit: … All images can be saved via the Web"), 這就是訓練資料被硬背下來的痕跡。
考點:
temperature與「模型好壞」無關,它只控制取樣的隨機程度。 低溫(0.1–0.3)適合需要穩定答案的任務;高溫(>1.0)會開始犧牲連貫性。
6. Gemini
清單裡寫的是 "Gemini / Bard (by Google)"——這個「雙名」本身就是考點。
6.1 為什麼有兩個名字
| 名稱 | 時期 | 說明 |
|---|---|---|
| Bard | 2023 年推出時 | Google 的對話式 AI 產品名 |
| Gemini | 2024 年改名 | 同一個產品改名,同時也變成模型家族的名字 |
改名之後,「Gemini」同時指兩件事:
- 模型家族:Gemini Ultra/Pro/Nano 等不同規模的模型
- 產品介面:gemini.google.com 那個聊天視窗
考點:之所以寫「Gemini / Bard」,是為了涵蓋改名前的舊稱。 考題若問「Google 的對話式 AI 叫什麼」,Bard 與 Gemini 都算對(Bard 是舊名)。
6.2 與 ChatGPT 的對照(要特別注意的差異)
| 比較項 | ChatGPT(OpenAI) | Gemini(Google) |
|---|---|---|
| 開發者 | OpenAI | |
| 與既有生態的結合 | 相對獨立 | 綁 Google 帳號與搜尋、Workspace |
| 取名邏輯 | 強調架構(GPT) | 強調「雙子」=多模態整合 |
6.3 「多模態」是 Gemini 的定位重點
Gemini 從設計上就是原生多模態(文字/圖片/音訊/影片一起吃)。 對照 §2 的定義——生成式 AI 的產出包含 images, text, music, videos—— Gemini 屬於「輸入端也支援多模態」的那一類,這是它與早期純文字模型的差別。
7. ChatGPT Prompt 範例
課程用一個例子示範「用 prompt 換取不同輸出」。它其實是 Lesson 5(Prompt Engineering) 的前導——那一課會把 prompt 拆成四大要素與七大類技術。
7.1 這一頁要你記住的最小觀念
同一個模型、同一句話,只要改 prompt 的寫法,輸出就會完全不同。 這是「Prompt Engineering」之所以成立的前提。
7.2 一個 prompt 的四個槽位(Lesson 5 會正式展開)
| 要素 | 英文 | 作用 | 例子 |
|---|---|---|---|
| 指令 | Instruction | 要模型做什麼 | 「幫我摘要」 |
| 上下文 | Context | 背景資訊 | 「這是給非技術主管看的」 |
| 輸入資料 | Input data | 要處理的內容 | 貼上一段文章 |
| 輸出指示 | Output indicator | 要什麼格式 | 「用三個 bullet、每個 15 字內」 |
考點:本課只要求你「知道 prompt 寫法會影響輸出」; 四大要素的細節屬於 Lesson 5 的範圍。若考題同時出現兩課內容,記住四要素的英文名。
8. Copilot
清單上寫的是 "Copilot (by Microsoft)"。
8.1 「Copilot」不是一個模型,是一個角色
這是本科最容易混淆的地方:Copilot 是微軟對「AI 助手」的產品命名, 背後的模型來自微軟與 OpenAI 的合作關係,而不是微軟自己從零訓練的模型。
| 名稱 | 廠商 | 意思 |
|---|---|---|
| GitHub Copilot | GitHub/Microsoft | 寫程式的助手 |
| Microsoft 365 Copilot | Microsoft | 綁 Word/Excel/Outlook/Teams |
| Windows Copilot | Microsoft | 綁作業系統 |
8.2 「Copilot(副駕駛)」這個命名的含義
選這個詞是有意義的——副駕駛不負責開飛機:
- 它輔助你,不取代你
- 最終決策與責任仍在人類身上
這個概念直接連到 Lesson 4「Responsible LLM」裡面的 Human Oversight(人類監督) 原則。
考點:問「Copilot 是哪家公司的」→ Microsoft。 問「Copilot 的模型是自己訓練的嗎」→ 不是,是基於與 OpenAI 的合作。
9. Meta/Llama
清單上寫的是 "Llama / Meta (by Meta / Facebook)"。
9.1 三個名字指同一件事的不同層次
| 名字 | 是什麼 |
|---|---|
| Meta | 公司(前身 Facebook) |
| Meta 的前身/旗下平台 | |
| Llama | Meta 發表的 LLM 模型家族(Large Language Model Meta AI) |
9.2 為什麼 Llama 在本課特別重要
Llama 是「開放權重(open weights)」路線的代表——模型權重可以下載回自己的電腦跑。 這條線直接連到本課程後面的兩個課節:
| 課節 | 用到的能力 |
|---|---|
| Lesson 6 — Hugging Face for LLM | 從 Hub 下載模型權重 |
| Lesson 7 — Local LLM Apps | 用 Ollama 在自己的機器上跑模型 |
換句話說:§9 是「本機 LLM」整條主線的起點。
9.3 開放權重 vs 開放原始碼
| 說法 | 意思 | Llama 屬於 |
|---|---|---|
| Open weights | 權重可下載,但授權有條件 | ✅ |
| Open source | 連訓練程式與資料都開放 | ❌(嚴格來說不是) |
考點:考題若把 Llama 說成「完全開源(open source)」,嚴格來說是錯的—— 正確說法是開放權重(open weights),授權有商用條件限制。
10. Grok
清單上寫的是 "Grok (by Elon Musk)"。
10.1 開發者要寫對
| 項目 | 正確答案 |
|---|---|
| 開發者 | xAI(Elon Musk 創辦的 AI 公司) |
| 說法 | by Elon Musk(用創辦人代表公司) |
| 深度整合的平台 | X(前 Twitter) |
考點:這裡用「Elon Musk」代表這家公司,但正式名稱是 xAI。 選項若同時出現「xAI」與「Elon Musk」,xAI 是公司名、Elon Musk 是創辦人,兩者不衝突。
10.2 Grok 的差異化定位
Grok 的賣點是即時存取 X 平台上的貼文——這是其他通用模型拿不到的資料源。 用 §3.1 的表格來看,它走的是「資料時效」這一欄的優勢路線。
11. Perplexity:AI 搜尋引擎
清單上寫的是 "Perplexity (AI Search Engine)"——括號裡的定位就是考點。
11.1 它為什麼不叫「聊天機器人」
| 比較項 | 通用聊天機器人 | Perplexity |
|---|---|---|
| 主要動作 | 依訓練記憶生成 | 先檢索、再生成 |
| 資料時效 | 訓練截止日 | 即時網頁 |
| 來源引用 | 通常沒有 | 每句都附來源 |
Perplexity 的運作方式就是 §29 要講的 RAG(Retrieval-Augmented Generation)的產品化: 先去網路上檢索相關頁面,再把檢索結果當上下文餵給 LLM 生成答案。
11.2 為什麼「AI 搜尋引擎」是準確的定位
它同時滿足「搜尋引擎」與「生成式 AI」的定義:
- 像搜尋引擎:輸入查詢、回傳當下的網路資訊
- 像生成式 AI:輸出是一段寫好的答案,不是連結清單
考點:考題問「哪一個產品被歸類為 AI Search Engine」→ Perplexity。 並要能說出理由:它用 RAG 把檢索結果交給 LLM 生成附來源的答案。
12. 中國熱門 LLM:Kimi、通義(Tongyi)、DeepSeek
標題是 Conversational Generative AI (China),列出三個:
| 產品 | 寫法 | 開發者 | 一句話定位 |
|---|---|---|---|
| Kimi | Kimi.ai | 月之暗面(Moonshot AI) | 主打超長上下文的對話助手 |
| 通義 | Tongyi | 阿里巴巴 | 阿里雲的模型家族(通義千問 Qwen) |
| DeepSeek | DeepSeek | 深度求索 | 開放權重、推理能力強,可本機跑 |
12.1 為什麼要獨立一節講中國的 LLM
因為這三個都是在全球榜上有名、且部分開放權重的模型。 特別是 DeepSeek——它同時是「中國模型」與「可下載到本機跑的模型」, 因此接著專門示範「DeepSeek to use locally」(見 §13)。
12.2 通義與 Qwen 的關係
| 名字 | 層次 |
|---|---|
| 通義(Tongyi) | 阿里巴巴的 AI 品牌名 |
| 通義千問(Qwen) | 品牌下的模型系列名稱 |
考點:本筆記的章節插圖就是用 Qwen-Image 生成的——Qwen 就是通義千問的模型名。 考題若問「Tongyi 是哪家公司」→ 阿里巴巴(Alibaba)。
12.3 這三個產品與 §3 六個產品的關係
把 §3 與 §12 合起來看,總共介紹了 9 個對話式生成式 AI:
§3 ChatGPT · Gemini · Copilot · Llama · Grok · Perplexity
§12 Kimi · Tongyi · DeepSeek
其中可以下載權重到自己電腦跑的是:Llama(Meta) 與 DeepSeek。 這兩個就是後續 Lesson 6/7 的主角。
13. 在本機使用 DeepSeek
這一頁是全課承先啟後的一頁:它把「熱門 LLM」這條主線接到「本機 LLM」這條主線。
13.1 「本機跑」是什麼意思
| 模式 | 模型在哪 | 資料去哪 | 需要網路嗎 |
|---|---|---|---|
| 雲端 API(ChatGPT、Gemini…) | 廠商的伺服器 | 送到廠商 | 要 |
| 本機推論(DeepSeek、Llama…) | 你自己的電腦/GPU | 不出你的機器 | 不用 |
13.2 為什麼要本機跑(四個理由)
| 理由 | 說明 |
|---|---|
| 隱私 | 資料不離開本機,適合機密文件 |
| 成本 | 沒有 per-token 費用(但要有 GPU) |
| 離線 | 斷網也能用 |
| 可控 | 可以自己微調、改參數、換版本 |
13.3 本機跑的三個代價
| 代價 | 說明 |
|---|---|
| 硬體 | 需要足夠的 VRAM;模型越大需求越高 |
| 品質 | 能在本機跑的多是「小模型」,能力遠不如雲端大模型 |
| 設定 | 要自己處理量化、記憶體、執行環境 |
考點:課程沒有給指令,但「本機跑 DeepSeek」= 開放權重 + 本機推論 這個組合是必考觀念。 後面 Lesson 7 會用 Ollama 把這件事做成一條指令。
13.4 對照 §5.6 的實測教訓
§5.6 已經在本機實測過一個小模型(distilgpt2,81.9 M 參數),結果是:
- 它能跑,而且很快(0.18 秒生成 10 個 token)
- 但它不會聽指令,只會接龍
「本機跑」解決的是隱私與成本,「模型夠不夠聰明」是另一回事—— 這正是課程把 DeepSeek 放進來的原因:它在本機可跑的小模型裡屬於推理能力較好的一類。
14. 第三方多模型聚合 App
14.1 什麼是「聚合 App」
一個介面、多個模型:使用者不必分別訂閱 ChatGPT/Gemini/Claude, 而是透過第三方 App 同時接多個模型,依需求切換。
14.2 這種架構的技術意義
聚合 App 必須解決「多供應商」的問題——每個供應商的 API 形狀都不同。 這正是 Lesson 8(LiteLLM) 要處理的核心問題:
LiteLLM 用 OpenAI 的 chat 格式統一呼叫 146 個供應商。
換句話說:§14 是 Lesson 8 的動機來源。
14.3 聚合 App 的三個風險
| 風險 | 說明 |
|---|---|
| 金鑰託管 | 你的 API Key 交給了第三方 |
| 中間人 | 你的 prompt 與回覆都經過第三方伺服器 |
| 模型版本不透明 | App 說「用 GPT-4」,但你無法驗證 |
考點:考題問「多模型聚合 App 的主要好處」→ 一個介面切換多個模型; 問「主要風險」→ API Key 與對話內容要交給第三方。
15. 生成式 AI 偵測器
15.1 為什麼需要偵測器
生成式 AI 可以產出「看起來像人寫的」文字與圖片,於是出現兩個需求:
| 需求 | 誰需要 |
|---|---|
| 辨識 AI 生成內容 | 學校(作業)、出版社(投稿)、平台(內容審核) |
| 標示 AI 生成內容 | 法規遵循(AI 生成內容的標籤要求) |
15.2 偵測器靠什麼判斷
| 方法 | 原理 | 弱點 |
|---|---|---|
| 統計特徵 | AI 文字的困惑度(perplexity)與突發性(burstiness)較低 | 改寫一下就可能失效 |
| 分類器 | 用「AI 寫的/人寫的」資料訓練一個判別模型 | 新一代模型沒見過就抓不到 |
| 浮水印 | 生成時就嵌入可偵測的訊號 | 需要模型端配合 |
15.3 最重要的一個觀念:偵測不是證明
偵測器輸出的是機率,不是證據。 這在 Lesson 4「Responsible LLM」裡屬於 可靠性(Reliability)與問責(Accountability) 的範疇:
- 誤判(把人類寫的說成 AI 寫的)會造成實際傷害
- 所以任何偵測結果都必須有人類覆核(Human Oversight)
考點:考題若問「AI 偵測器的結果能否作為抄襲的定論」→ 不能, 它是機率性判斷,必須搭配人工審查。
16. Predictive AI vs Generative AI:主題地圖
課程是第二條主線的總覽,四個 bullet:
| bullet | 中文 | 本筆記章節 |
|---|---|---|
| • Recap of Predictive AI | 預測式 AI 回顧 | §17–§18 |
| • Basic Concepts in GAN Network | GAN 基礎概念 | §23 |
| • Underlying Technologies and Algorithms | GAN 的底層技術與演算法 | §24 |
| • Hybrid AI Systems | 混合式 AI 系統 | §27 |
16.1 這份目錄透露的編排邏輯
課程把「Predictive AI vs Generative AI」這一節編成三層:
第一層:兩種 AI 各自是什麼 → §17–§22
第二層:生成式 AI 的三種實現方式 → §23–§26
GAN / Diffusion / 其他(VAE、AR)
第三層:把兩種 AI 合起來用 → §27–§28
Hybrid AI Systems + 真實應用
16.2 為什麼「GAN」被放在「生成式 AI」底下
因為 GAN 是生成式 AI 最早、最經典的實現方式之一:
- 它不是「預測」——它產生新資料
- 它用對抗的方式訓練——這是它獨有的機制
所以 §23–§24 花了很多頁講 GAN,接著 §25 才講 Diffusion(另一個主流實現)。
考點:四個 bullet 的順序常被當成配對題: Recap → GAN → Underlying Technologies → Hybrid。
17. Predictive AI 深入:資料、模型與應用
課程用三段文字定義 Predictive AI,這是本科最完整的一段敘述。
17.1 三段敘述
| 小標 | 內容 | 中文 |
|---|---|---|
| Data-Driven Insights | relies on large datasets — customer behavior, financial records, sensor data — to identify patterns and correlations | 靠大數據找模式與相關性 |
| Machine Learning Models | common algorithms include regression models, decision trees, random forests, neural networks, and ensemble methods | 五類常見演算法 |
| Applications | Business/Healthcare/Finance/Other Fields | 四領域的實例 |
17.2 五種常見演算法(必背)
| 演算法 | 英文 | 一句話 |
|---|---|---|
| 迴歸模型 | Regression models | 預測連續數值(房價、溫度) |
| 決策樹 | Decision trees | 一連串 if-else 切分 |
| 隨機森林 | Random forests | 很多棵決策樹投票 |
| 神經網路 | Neural networks | 多層網路學非線性關係 |
| 集成方法 | Ensemble methods | 把多個弱模型合成一個強模型 |
考點:課程把這五個並列在同一句裡,考題會問「下列何者不是課程列出的預測式 AI 演算法」。 注意 ensemble methods(集成方法) 很容易被漏掉——它是第五個。
17.3 四個應用領域(分類)
| 領域 | 舉的例子 |
|---|---|
| Business | Customer churn prediction(客戶流失預測)、sales forecasting(銷售預測)、demand planning(需求規劃)、personalized marketing(個人化行銷) |
| Healthcare | Disease outbreak prediction(疫情預測)、patient diagnosis(診斷)、treatment outcome forecasting(治療結果預測) |
| Finance | Credit scoring(信用評分)、fraud detection(詐欺偵測)、stock market trend analysis(股市趨勢) |
| Other Fields | Weather forecasting(天氣預報)、predictive maintenance(預測性維護)、traffic flow optimization(車流優化) |
考點:fraud detection(詐欺偵測) 在課程裡同時出現在 Finance 應用與 §21 的對照表中, 是出現頻率最高的例子。predictive maintenance(預測性維護) 是製造業的經典例子。
18. Predictive AI 的五步流程
預測式 AI 的標準流程有五步,順序必須記牢:
① Data Collection 蒐集資料
↓
② Data Preprocessing 清理與整理
↓
③ Model Training 用歷史資料訓練
↓
④ Prediction & Validation 產生預測並評估準確度
↓
⑤ Deployment 整合進決策流程
18.1 五步的關鍵詞對照
| # | 英文 | 中文 | 這一步的關鍵詞 |
|---|---|---|---|
| ① | Data Collection | 資料蒐集 | relevant and high-quality data |
| ② | Data Preprocessing | 資料前處理 | cleaning and organizing |
| ③ | Model Training | 模型訓練 | using historical data |
| ④ | Prediction and Validation | 預測與驗證 | generating forecasts and evaluating accuracy |
| ⑤ | Deployment | 部署 | integrating into decision-making processes |
18.2 最容易考錯的兩個地方
| 陷阱 | 說明 |
|---|---|
| 「訓練」不是第一步 | 第一步一定是蒐集資料;「模型訓練」是第三步 |
| 「驗證」與「預測」同一階段 | 課程把 Prediction 與 Validation 放在同一個 bullet,不是兩個獨立階段 |
18.3 本機實測:完整跑一次這五步
本課的 Lab GenAI/Predictive AI.ipynb 就是把這五步寫成程式。本機實測
(numpy 2.4.6/pandas 3.0.6/scikit-learn,RTX 4090):
# 對應 ① 資料蒐集 + ② 資料前處理:用公式「生成」一份房價資料
import numpy as np, pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, r2_score
from sklearn.model_selection import train_test_split
np.random.seed(42) # 這行被註解掉了 → 每次跑結果都不同
n = 100
size = np.random.randint(500, 3500, n) # 坪數
rooms = np.random.randint(1, 6, n) # 房間數
loc = np.random.randint(1, 11, n) # 地段分數
price = (size * 300) + (rooms * 10000) + (loc * 5000) \
+ np.random.randint(-20000, 20000, n) # ← 加上 ±20000 的雜訊
df = pd.DataFrame({"Size_sqft": size, "Rooms": rooms,
"Location_Score": loc, "Price": price})
# ③ 模型訓練
X, y = df[["Size_sqft", "Rooms", "Location_Score"]], df["Price"]
Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.2, random_state=42)
model = LinearRegression().fit(Xtr, ytr)
# ④ 預測與驗證
yp = model.predict(Xte)
print("MAE = ${:,.2f}".format(mean_absolute_error(yte, yp)))
print("R² = {:.2f}".format(r2_score(yte, yp)))
# ⑤ 部署:對新的輸入給出預測
new = pd.DataFrame({"Size_sqft": [2000], "Rooms": [3], "Location_Score": [8]})
print("預測房價 = ${:,.2f}".format(model.predict(new)[0]))
本機實測輸出(seed=42,可重現):
MAE = $11,227.31
R2 = 1.00
intercept_ = -1,617.09
coef Size_sqft = 300.6864
coef Rooms = 9,406.3006
coef Location_Score = 5,223.7014
預測 2000 平方呎 / 3 房 / location 8 -> $669,764.15
18.4 ⚠️ 最重要的發現:R² = 1.00 不代表模型很好
這是本科最容易被誤解的一個數字。把上面的結果和資料的產生公式對照:
| 參數 | 資料產生公式的真值 | 模型學到的係數 | 誤差 |
|---|---|---|---|
| Size_sqft | 300 | 300.6864 | +0.69 |
| Rooms | 10,000 | 9,406.3006 | −594 |
| Location_Score | 5,000 | 5,223.7014 | +224 |
| 雜訊 | ±20,000 | (學不到,只能算進 MAE) | — |
為什麼 R² 會是 1.00(四捨五入後)?
因為資料是用一條直線公式產生的,而我們用的模型也是線性迴歸—— 模型的形式與資料的產生機制完全一致,所以它幾乎完美擬合。
這在真實世界不會發生:真實資料不會剛好由一條直線產生。所以:
考點:
R² = 1.00只能證明「模型形式與資料產生機制吻合」, 不能證明「模型在真實資料上有效」。 考題若問「本 Lab 的 R² 為何接近 1」,正確答案是 「因為資料是用線性公式合成的,而模型也是線性模型」, 而不是「因為線性迴歸是最好的演算法」。
18.5 MAE 為什麼大約是 1 萬
雜訊項是 np.random.randint(-20000, 20000, n),均勻分布於 ±20,000。
均勻分布的平均絕對偏差約為區間寬度的 1/4:
20000 / 4 ≈ 5,000 (理論下限)
實測 MAE 是 11,227,比理論值高——因為測試集只有 20 筆, 樣本少導致波動大(另一次不設 seed 的實測是 9,466)。
考點:
train_test_split(test_size=0.2)在 n=100 時測試集只有 20 筆。 樣本這麼少時,MAE 每次都會明顯跳動——這也是「故意不設 seed」想讓你看到的現象。
19. Generative AI 深入:定義與核心技術
19.1 第二次定義(對比式)
這個定義比前一個更完整,因為它加上了與 Predictive AI 的對比:
Generative AI refers to artificial intelligence systems that create new content, such as text, images, audio, video, or code, by learning patterns from existing data. Unlike predictive AI, which forecasts outcomes, generative AI produces original outputs that mimic or extend the characteristics of its training data.
| 關鍵詞 | 中文 | 為什麼重要 |
|---|---|---|
| create new content | 產生新內容 | 與「預測」相對 |
| by learning patterns from existing data | 從既有資料學模式 | 不是規則式 |
| Unlike predictive AI, which forecasts outcomes | 對比:預測式 AI 是預測結果 | 定義裡直接寫了對照 |
| original outputs | 原創輸出 | 每次輸出都可能不同 |
| mimic or extend | 模仿或延伸 | 「延伸」=可以生成訓練資料沒有的組合 |
19.2 四種核心技術(必背)
課程列出 Core Technologies,分成三組:
| 分組 | 內容 |
|---|---|
| Machine Learning Models | Generative Adversarial Networks (GANs)、Variational Autoencoders (VAEs)、Transformers、diffusion models |
| Diffusion Models | 影像生成的主流(例:DALL·E、Stable Diffusion) |
| Large Language Models (LLMs) | 文字生成(例:GPT(用於 ChatGPT)、LLaMA) |
整理成表:
| 技術 | 擅長 | 本課後續 |
|---|---|---|
| GAN | 影像(對抗式訓練) | §23–§24 |
| VAE | 潛在表徵、去噪 | §26 |
| Transformer | 序列/文字 | Lesson 3 |
| Diffusion | 高品質影像 | §25 |
| LLM | 文字 | 全課主軸 |
考點:課程把 Transformers 也列為「生成式 AI 的核心技術」之一—— 因為 ChatGPT 的 T 就是 Transformer。考題常問「下列何者不是生成式 AI 的核心技術」, 而 Transformer 很容易被誤認為只是「NLP 的東西」。
19.3 產品對應舉例
| 寫的例子 | 屬於哪一類 | 開發者 |
|---|---|---|
| DALL·E | Diffusion(影像) | OpenAI |
| Stable Diffusion | Diffusion(影像) | Stability AI |
| GPT(用於 ChatGPT) | LLM(文字) | OpenAI |
| LLaMA | LLM(文字) | Meta |
考點:DALL·E 與 Stable Diffusion 都是擴散模型,不是 GAN。 這是最常見的配對錯誤之一。
20. Generative AI 的運作方式與生成流程
20.1 三個階段(How It Works)
| 階段 | 英文 | 中文 | 關鍵詞 |
|---|---|---|---|
| ① | Training | 訓練 | trained on vast datasets to learn patterns, structures, or styles |
| ② | Generation | 生成 | sampling from learned distributions or responding to prompts |
| ③ | Fine-Tuning | 微調 | tailored for specific tasks or styles via fine-tuning or prompt engineering |
注意第 ③ 點的一個細節:課程把 fine-tuning(微調) 與 prompt engineering(提示工程) 並列為「客製化的兩種手段」。這兩者的成本差距極大:
| 手段 | 改什麼 | 成本 | 需要重新訓練嗎 |
|---|---|---|---|
| Fine-tuning | 改模型權重 | 高(要資料 + GPU) | 要 |
| Prompt engineering | 只改輸入 | 低(改幾個字) | 不用 |
20.2 三步使用者流程(Process)
從使用者視角再講一次流程:
① Input a prompt or seed 輸入提示或種子
(e.g., text description, partial image)
↓
② Model generates output 模型依學到的模式生成輸出
based on learned patterns
↓
③ Users may iterate 使用者反覆調整
by refining prompts or post-processing outputs
20.3 兩頁的差別:一個是「系統怎麼做」、一個是「使用者怎麼用」
| How It Works | Process | |
|---|---|---|
| 視角 | 系統內部 | 使用者操作 |
| 步驟 | Training → Generation → Fine-Tuning | Input → Generate → Iterate |
| 重點 | 模型的三個生命階段 | 使用者的三步循環 |
考點:
seed(種子) 這個詞只出現在課程,指的是「輸入的一部分」 (文字描述或半張圖)。在擴散模型裡 seed 是「起始的隨機雜訊」——下面的實測會用到它。
20.4 本機實測:完整跑一次「生成」流程
本課的 Lab GenAI/Gen AI.ipynb 用 Stable Diffusion 1.5 實作這個流程。
本機實測(diffusers/RTX 4090):
import os, sys
sys.path.insert(0, "_shim") # 見附錄 B:繞過本機 torchaudio 的 CUDA 版本問題
import torch
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", use_safetensors=True)
pipe = pipe.to("cuda").to(dtype=torch.float16) # GPU 用 float16、CPU 用 float32
img = pipe(
"A curious robot exploring a futuristic city",
num_inference_steps=20, # 滑桿範圍 10–50,預設 20
guidance_scale=7.5, # 滑桿範圍 1.0–20.0,預設 7.5
height=512, width=512, # 固定 512×512
).images[0]
img.save("robot.png")
本機實測輸出:
torch 2.14.1+cu132 | cuda True
gpu NVIDIA GeForce RTX 4090 | VRAM 24.0 GB
load pipeline: 7.24 s
n_params = 859.5 M (unet 部分)
steps=10 guidance=7.5 -> 0.78 s peak VRAM 5.13 GB
steps=20 guidance=7.5 -> 0.61 s peak VRAM 5.13 GB
steps=30 guidance=7.5 -> 0.81 s peak VRAM 5.13 GB
steps=20 guidance=1.0 -> 0.57 s
steps=20 guidance=7.5 -> 0.60 s
steps=20 guidance=15.0 -> 0.60 s
三個可以直接寫進考卷的觀察:
- 課程說「may take 30-60 seconds」,在本機 4090 上只要 0.6–0.8 秒—— 數字是 Google Colab 免費 GPU(T4 等級) 的體感。 同一個模型、同一組參數,硬體不同就差 50 倍。
- 步數從 10 增加到 30,時間幾乎沒變(0.78 → 0.81 秒)。 因為在 512×512 這種小尺寸下,時間主要花在固定的資料搬移與排程開銷, 真正的 U-Net 前向傳播反而很快。步數的影響要在大尺寸(1024×1024)才明顯。
- 峰值 VRAM 只要 5.13 GB——
float16是關鍵(寫法正確)。 如果改成float32,記憶體需求大約會翻倍。
考點:
guidance_scale與num_inference_steps的預設值是 7.5 與 20,範圍是 1.0–20.0 與 10–50。這組數字常被直接考出來。
21. 對照總表:Predictive AI vs Generative AI
課程用左右兩欄做總結對照,這是本科最高頻的考題來源。
21.1 左右兩欄的對照
| Predictive AI | Generative AI | |
|---|---|---|
| 核心動作 | Forecast future outcomes based on historical data | Create new content that didn't exist before |
| 方法 | Uses statistical models and machine learning to identify patterns and trends | Trained on large datasets to generate text, images, music, code, and more |
| 例子 | • Predicting stock prices or weather • Recommending products based on past purchases • Detecting fraud in financial transactions |
• Writing essays or poems • Creating realistic images or videos • Generating synthetic voices or music |
21.2 一張表背完(考試用)
| 比較項 | Predictive AI | Generative AI |
|---|---|---|
| 產出 | 一個數值/類別 | 一份新內容 |
| 資料方向 | 過去 → 未來 | 學習 → 創造 |
| 輸出是否唯一 | 同輸入通常同輸出 | 同輸入每次可能不同 |
| 評估方式 | 準確率、MAE、R² | 人工評分、FID、困惑度 |
| 代表技術 | 迴歸、決策樹、隨機森林、神經網路、集成 | GAN、VAE、Transformer、Diffusion、LLM |
| 代表產品 | (無特定品牌) | ChatGPT、DALL·E、Stable Diffusion |
| 典型任務 | 預測股價、推薦商品、偵測詐欺 | 寫文章、畫圖、生成語音 |
21.3 最容易混淆的三組例子
| 例子 | 屬於 | 為什麼 |
|---|---|---|
| Detecting fraud(偵測詐欺) | Predictive | 判斷「這筆是不是詐欺」=分類 |
| Generating synthetic voices(生成合成語音) | Generative | 產出新的音訊內容 |
| Recommending products(推薦商品) | Predictive | 預測「你可能會買什麼」 |
考點:判斷的唯一標準是「它輸出的是預測還是新內容」。 看到 "predict"、"forecast"、"detect"、"classify"、"recommend" → Predictive; 看到 "write"、"create"、"generate"、"draw"、"compose" → Generative。
22. AI → ML → DL → Generative AI 的層次,與 AIGC
Generative AI and AIGC)。
22.1 四層同心圓(必背)
課程給出四層包含關係,右邊是定義:
| 層 | 定義 |
|---|---|
| Artificial Intelligence (AI) | simulates human intelligence in machines to perform tasks autonomously |
| Machine Learning | enables systems to learn from data and improve automatically |
| Deep Learning | uses multi-layered neural networks to model complex data patterns |
| Generative AI | creates new content by learning patterns from existing data |
課程用一張同心圓圖表示(AI ⊃ ML ⊃ DL ⊃ Generative AI):
每一個都包含在下一個裡面——所以「生成式 AI 是 AI 的一種」這句話是對的, 反過來「AI 就是生成式 AI」是錯的。
考點:這四層的包含順序是最常考的:AI ⊃ ML ⊃ DL ⊃ Generative AI。 注意 Deep Learning 的定義關鍵詞是「multi-layered neural networks(多層神經網路)」。
22.2 PGC / UGC / AIGC
課程用三個縮寫切分「內容的三種來源」:
| 縮寫 | 全稱 | 中文 | 例子 |
|---|---|---|---|
| PGC | Professionally-created content | 專業生產內容 | 電影、報紙、出版社書籍 |
| UGC | User-generated content | 使用者生成內容 | 部落格、YouTube、社群貼文 |
| AIGC | AI-Generated Content | AI 生成內容 | ChatGPT 寫的文章、Stable Diffusion 畫的圖 |
引文:
"Generate a diverse range of content such as written text, visual images, auditory files, and generated synthetic data."
22.3 三者的界線正在模糊
| 現象 | 說明 |
|---|---|
| AI 輔助的 UGC | 人寫大綱、AI 補內容 → 算 UGC 還是 AIGC? |
| AI 生成的 PGC | 出版社用 AI 生成插圖 → 品質達 PGC 標準,來源是 AI |
| 標示義務 | 這就是 §15「AI 偵測器」與 Lesson 4「Responsible LLM」要處理的問題 |
考點:AIGC = AI-Generated Content,是「內容」的分類,不是「模型」的分類。 考題若問「ChatGPT 產出的文章屬於哪一類」→ AIGC。
23. GAN 基礎概念
課程用四頁建立 GAN 的基本概念,其中幾頁的標題重複出現「• Basic Concepts in GAN Network」
23.1 GAN 的定義
Generative Adversarial Networks (GANs) are a type of machine learning framework used to generate new data instances that resemble a training dataset. They are a popular approach in generative AI, utilizing two neural networks, a generator and a discriminator, in a competitive, adversarial process.
三個關鍵:
| 關鍵 | 意思 |
|---|---|
| generate new data instances | 產出「新的資料樣本」 |
| resemble a training dataset | 產出的東西要像訓練資料 |
| two networks, adversarial | 兩個網路、對抗訓練 |
23.2 用「非監督式生成建模」的角度再定義一次
Generative Adversarial Networks, or GANs for short, are an approach to generative modeling using deep learning methods, such as convolutional neural networks.
Generative modeling is an unsupervised learning task in machine learning that involves automatically discovering and learning the regularities or patterns in input data in such a way that the model can be used to generate or output new examples that plausibly could have been drawn from the original dataset.
這裡有兩個容易考的標籤:
| 標籤 | 說明 |
|---|---|
| unsupervised learning task | 生成建模屬於非監督式學習(不需要人工標籤) |
| convolutional neural networks | GAN 常用 CNN 當骨幹(尤其是影像) |
考點:「生成建模是非監督式學習」——因為它不需要標籤, 只需要一堆「真資料」。這常與「GAN 內部有兩個網路互相對抗」一起考。
23.3 零和賽局(zero-sum game)
GANs are a clever way of training a generative model by framing the problem as a supervised learning problem with two sub-models: the generator model that we train to generate new examples, and the discriminator model that tries to classify examples as either real (from the domain) or fake (generated). The two models are trained together in a zero-sum game, adversarial, until the discriminator model is fooled about half the time, meaning the generator model is generating plausible examples.
這裡藏了一個很反直覺的考點:
| 課程說明 | 意思是 |
|---|---|
| 「framing the problem as a supervised learning problem」 | 把生成問題改寫成監督式問題(因為判別器在做分類,有「真/假」標籤) |
| 但 §23.2 說 generative modeling 是 unsupervised | 兩者不矛盾:任務本質非監督,但訓練手法借用監督式分類 |
「訓練成功的標準」:判別器被騙到大約一半(about half the time)—— 因為那代表它只能亂猜,也就是生成器的輸出已經與真資料難以區分。
考點:「判別器準確率降到 50%」代表訓練成功,不是失敗。 這是 GAN 最反直覺、也最常考的一點。
23.4 How it works(三方互動)
課程用三個 bullet 描述對抗過程:
| 誰 | 做什麼 |
|---|---|
| Generator | attempts to generate data that the discriminator will classify as real |
| Discriminator | learns to identify the subtle differences between real and fake data |
| Adversarial training | continues until the generator becomes proficient at producing data that the discriminator can't distinguish from real data |
23.5 GAN 能做出什麼
課程特別舉了兩類成果:
| 類型 | 例子 |
|---|---|
| Image-to-image translation | 夏天照片 → 冬天、白天 → 夜晚 |
| Photorealistic generation | 生成「連人類都分不出真假」的照片 |
考點:image-to-image translation(例如 day to night)是 GAN 最經典的應用之一。 考題若問「GAN 的著名應用」,除了「生成逼真圖片」也要記得「風格/季節轉換」。
24. GAN 的底層技術與演算法
其餘各頁才有實質內容。
課程用相當篇幅展開 GAN 的訓練機制,是本科最技術的一段。
24.1 兩個網路怎麼接起來
Both the generator and the discriminator are neural networks. The generator output is connected directly to the discriminator input. Through backpropagation, the discriminator's classification provides a signal that the generator uses to update its weights.
關鍵:生成器的輸出直接接判別器的輸入,所以梯度可以一路回傳到生成器。
24.2 判別器的訓練程序(Discriminator training)
課程列出三步:
| # | 英文 | 中文 |
|---|---|---|
| ① | The discriminator classifies both real data and fake data from the generator | 判別器同時分類真資料與生成器產的假資料 |
| ② | The discriminator loss penalizes the discriminator for misclassifying a real instance as fake or a fake instance as real | 判別器損失對兩種錯誤都罰 |
| ③ | The discriminator updates its weights through backpropagation from the discriminator loss through the discriminator network | 只更新判別器自己的權重 |
注意第 ③ 點的關鍵限定:through the discriminator network——
訓練判別器時,生成器的權重不動。
24.3 生成器的訓練程序(Generator training)
課程給出六步(比判別器多了三步,因為要「穿過」判別器回傳梯度):
① Sample random noise. 取樣隨機雜訊
② Produce generator output from sampled random noise. 生成器產出假資料
③ Get discriminator "Real" or "Fake" classification 取得判別器的判定
for generator output.
④ Calculate loss from discriminator classification. 由判定算損失
⑤ Backpropagate through BOTH the discriminator AND 梯度穿過「兩個」網路
generator to obtain gradients.
⑥ Use gradients to change ONLY the generator weights. 只改「生成器」權重
第 ⑤ 與第 ⑥ 步是必考點:
| 步驟 | 關鍵限定詞 | 為什麼 |
|---|---|---|
| ⑤ | both the discriminator and generator | 梯度必須穿過判別器才能到達生成器 |
| ⑥ | only the generator weights | 判別器的權重凍結,不能改 |
24.4 兩個網路的角色對照
| Generator(生成器) | Discriminator(判別器) | |
|---|---|---|
| 輸入 | 隨機雜訊(random noise) | 真資料或生成資料 |
| 輸出 | 合成資料(synthetic data,如圖片) | 「真」或「假」的預測 |
| 目標 | 騙過判別器 | 正確分辨真假 |
| 原文 | Takes random noise as input and generates synthetic data | Takes real or generated data and predicts whether it's real or fake |
24.5 交替訓練(alternating periods)
GAN training proceeds in alternating periods: • The discriminator trains for one or more epochs. • The generator trains for one or more epochs. • Repeat steps 1 and 2 to continue to train the generator and discriminator networks.
重點:不是「一起訓練」,而是輪流訓練——這是 GAN 訓練不穩定的根本原因。
24.6 收斂(Convergence)與崩壞
這是課程最重要的一段,原文:
As the generator improves with training, the discriminator performance gets worse because the discriminator can't easily tell the difference between real and fake. If the generator succeeds perfectly, then the discriminator has a 50% accuracy. In effect, the discriminator flips a coin to make its prediction.
This progression poses a problem for convergence of the GAN as a whole: the discriminator feedback gets less meaningful over time. If the GAN continues training past the point when the discriminator is giving completely random feedback, then the generator starts to train on junk feedback, and its own quality may collapse.
拆成三個階段:
| 階段 | 判別器 | 生成器 | 結果 |
|---|---|---|---|
| 早期 | 很強(輕鬆分辨真假) | 很弱 | 梯度訊號強,學習快 |
| 理想 | 50% 準確率(擲硬幣) | 已能產出逼真資料 | ✅ 收斂 |
| 過頭 | 完全隨機的回饋 | 開始學垃圾訊號 | ❌ 品質崩壞(collapse) |
考點:「訓練太久反而變差」 是 GAN 獨有的現象。 正確答案是「判別器的回饋會變得沒有意義(junk feedback),導致生成器崩壞」, 而不是「生成器過擬合」。
24.7 損失函數(Loss Functions)
GANs try to replicate a probability distribution. They should therefore use loss functions that reflect the distance between the distribution of the data generated by the GAN and the distribution of the real data.
| 概念 | 說明 |
|---|---|
| 目標 | 複製一個機率分布 |
| 損失函數該衡量什麼 | 生成資料分布 ↔ 真資料分布之間的距離 |
考點:GAN 的損失函數不是衡量「這張圖像不像」,而是衡量 「兩個分布的距離」。這是它與一般分類/回歸任務在損失設計上的根本差別。
25. Diffusion Model
課程介紹擴散模型,這是目前影像生成的主流技術(Stable Diffusion、DALL·E 都屬於此類)。
25.1 定義與雙相機制
Diffusion models are advanced machine learning algorithms that uniquely generate high-quality data by progressively adding noise to a dataset and then learning to reverse this process. This innovative approach enables them to create remarkably accurate and detailed outputs, from lifelike images to coherent text sequences.
Diffusion models work in a dual-phase mechanism: They first train a neural network to introduce noise into the dataset (a staple in the forward diffusion process) and then methodically reverse this process.
一句話:先學會加噪,再學會去噪。
25.2 兩個核心過程
| 過程 | 標題 | 說明 | 白話 |
|---|---|---|---|
| Forward Process | Forward Process (Noise Addition) | Gaussian noise is incrementally added to the data over multiple steps, transforming it into pure noise | 一步一步加高斯雜訊,最後變成純雜訊 |
| Reverse Process | Reverse Process (Denoising) | The model learns to reverse this process, gradually removing noise to reconstruct the original data distribution | 學會倒著走,逐步去噪還原 |
考點:Forward 是加噪、Reverse 是去噪,順序不能顛倒。 而且只有 Reverse 需要訓練——Forward 只是一個固定的加噪公式。
25.3 SDE(隨機微分方程)
Stochastic differential equations (SDEs): SDEs are mathematical tools that describe the noise addition process in diffusion models.
| 縮寫 | 全稱 | 在擴散模型裡的角色 |
|---|---|---|
| SDE | Stochastic Differential Equation | 描述連續時間下加噪過程的數學工具 |
為什麼需要它:離散步驟(第 1 步、第 2 步…)的加噪,在步驟趨近無限多時, 就變成一條連續的隨機過程,需要用 SDE 描述。
25.4 DDPM
Denoising diffusion probabilistic models (DDPMs) are a specific type of diffusion model that focuses on probabilistically removing noise from data.
| 縮寫 | 全稱 | 特徵 |
|---|---|---|
| DDPM | Denoising Diffusion Probabilistic Model | 機率式去噪;品質高但取樣慢 |
25.5 優點與挑戰
| 類別 | 內容 | 中文 |
|---|---|---|
| High-Quality Outputs | Diffusion models excel at generating detailed and realistic samples | 細節與真實度極佳 |
| Flexibility | Applicable to various data types (images, audio, text) | 可跨模態 |
| Challenges | Slow sampling due to iterative steps, though techniques like DDIM or faster samplers mitigate this | 取樣慢;用 DDIM 等加速器緩解 |
25.6 DDIM 是什麼(課程點到為止,這裡補完)
| 模型 | 全稱 | 特性 |
|---|---|---|
| DDPM | Denoising Diffusion Probabilistic Model | 機率式,需要很多步(通常 1000 步) |
| DDIM | Denoising Diffusion Implicit Model | 確定性、可跳步,幾十步就能出圖 |
考點:DDIM 是 DDPM 的「加速取樣器」,不是另一種全新的生成模型。 考題常把 DDIM 描述成「另一種生成架構」——那是錯的。
25.7 本機實測:num_inference_steps 就是「Reverse 的步數」
課程說「取樣慢是因為 iterative steps」,這句話可以用 §20.4 的實測直接驗證:
| 參數 | 就是課程說的 | 本機實測(SD 1.5,512×512,RTX 4090) |
|---|---|---|
num_inference_steps=10 |
去噪 10 步 | 0.78 秒 |
num_inference_steps=20 |
去噪 20 步(預設) | 0.61 秒 |
num_inference_steps=30 |
去噪 30 步 | 0.81 秒 |
在 512×512 這個尺寸下,步數從 10 增加到 30,時間幾乎不變—— 因為時間被固定的排程與資料搬移開銷吃掉了。 課程說「慢」是相對於 GAN 的單次前向傳播而言(GAN 一次就出圖,擴散要迭代幾十次)。
考點:擴散模型的「慢」是相對 GAN 的單次生成而言。 在現代 GPU 上,512×512 只要不到 1 秒——課程寫的「30–60 秒」是 Colab 免費 GPU 的數字。
26. GAN vs Diffusion,與其他生成模型
26.1 GAN vs Diffusion 的六個維度
把 §23–§25 的內容整理成可直接背的表:
| 比較項 | GAN | Diffusion |
|---|---|---|
| 核心機制 | 生成器 vs 判別器,對抗 | 加噪 → 去噪 |
| 訓練方式 | 兩個網路輪流訓練 | 單一網路,穩定訓練 |
| 生成速度 | 快(一次前向傳播) | 慢(需迭代數十步) |
| 輸出品質 | 高但容易模式崩壞 | 高且多樣 |
| 訓練穩定性 | 差(可能崩壞,見 §24.6) | 好 |
| 代表產品 | 早期的 StyleGAN 等 | Stable Diffusion、DALL·E |
26.2 為什麼現在主流是 Diffusion
| 原因 | 說明 |
|---|---|
| 訓練穩定 | 不需要平衡兩個網路,不會「訓練過頭反而崩壞」 |
| 多樣性好 | GAN 容易只學會少數幾種樣本(mode collapse) |
| 可控性強 | 步數、guidance scale 都是直覺可調的旋鈕 |
代價是生成速度——但可以靠 DDIM/蒸餾等方法補回來。
26.3 其他兩種生成模型
另有兩個不在 §19.2 清單裡的模型:
| 模型 | 定義 | 中文 |
|---|---|---|
| VAE | A Variational Autoencoder is a generative machine learning model that combines neural networks with Bayesian inference to learn latent representations of data. It's used for tasks like data generation, denoising, and representation learning. | 用神經網路 + 貝氏推論學潛在表徵 |
| AR | An Autoregressive Model is a type of statistical or machine learning model used for time series analysis or sequential data generation. It predicts the current data point based on a function of its previous data points. The core idea is that the output at time t, denoted X_t, depends on past values X_{t-1}, X_{t-2}, … | 用前面的值預測下一個值 |
26.4 AR 為什麼和 LLM 有關
LLM 就是自迴歸模型——它一次預測一個 token,然後把剛生成的 token 接回去繼續預測下一個。 公式 X_t = f(*X_{t-1}, X_{t-2}, …) 正是這個機制。
| 模型 | 生成順序 | 例子 |
|---|---|---|
| AR(自迴歸) | 一次一個(序列) | GPT 系列、LLaMA |
| Diffusion | 全部同時(迭代去噪) | Stable Diffusion |
| GAN | 一次前向 | StyleGAN |
| VAE | 一次解碼 | 經典 VAE |
考點:四種生成模型都可以用「生成的順序」來區分: AR 是逐個生成、Diffusion 是整體迭代、GAN/VAE 是一次前向。 這個分類法幾乎每年都考。
27. Hybrid AI Systems
27.1 預測式 + 生成式 = 混合式
定義:
Predictive AI and Generative AI can form a synergistic system that can both anticipate and create, enabling smarter, more adaptive, and more human-like decision-making.
課程把它寫得更明確:
| 元件 | 角色 |
|---|---|
| Predictive AI | Uses historical data and machine learning to forecast future outcomes |
| Generative AI | Creates new content (text, images, code, etc.) based on learned patterns |
| Hybrid | Together, they form a synergistic system that can both anticipate and create |
27.2 另一種「混合」——符號式 + 次符號式
課程另有另一組混合定義(不是預測 vs 生成,而是規則 vs 學習):
Hybrid AI (Hybrid Artificial Intelligence) refers to the integration of different AI paradigms within a single system to leverage their individual strengths and compensate for their weaknesses. The most common combination is:
| 類型 | 定義 | 優點 |
|---|---|---|
| Symbolic AI(符號式) | Uses logic and rules to make decisions | 可解釋、擅長結構化推理 |
| Sub-symbolic AI(次符號式) | Machine Learning/Neural Networks;learns from data | 擅長模式辨識,但缺乏透明度 |
課程說合起來可以:
- Learn from data like humans do(像人一樣從資料學習)
- Follow rules and logic like traditional expert systems(像專家系統一樣依規則推理)
- Be more explainable and trustworthy(更可解釋、更可信任)
考點:Hybrid AI 有兩種定義,考題要看清問的是哪一種: ① Predictive + Generative ② Symbolic + Sub-symbolic() 兩者都是 Hybrid AI,但講的是不同的「混合」。
27.3 為什麼「可解釋性」是混合式的核心賣點
| 純次符號式(深度學習) | 混合式 |
|---|---|
| 給出答案,但說不出理由 | 規則部分說得出理由 |
| 難以通過法規審查 | 可對應到 Lesson 4 的 Accountability 與 Human Oversight |
28. 真實世界應用:醫療、電商、招聘
課程給出三個產業的同一個模式:Predictive 負責判斷、Generative 負責產出內容、 Hybrid 負責把兩者接起來。
28.1 Healthcare Diagnostics(醫療診斷)
| 角色 | 做什麼 |
|---|---|
| Predictive AI | analyzes patient history to forecast disease risk |
| Generative AI | creates personalized treatment summaries or generates synthetic medical images for training |
| Hybrid AI | flags uncertain cases for doctor review, ensuring both accuracy and explainability |
注意 Generative AI 在這裡的兩個用途:
| 用途 | 說明 |
|---|---|
| 產生個人化治療摘要 | 把檢驗數據轉成病人看得懂的說明 |
| 產生合成醫學影像 | 用來擴充訓練資料(醫學影像取得困難、有隱私問題) |
28.2 E-commerce(電商)
| 角色 | 做什麼 |
|---|---|
| Predictive AI | forecasts customer behavior and product demand |
| Generative AI | writes personalized product descriptions or chatbot responses |
| Hybrid AI | ensures the generated content aligns with predicted customer intent |
Hybrid 在這裡的價值:不是「生成就好」,而是「生成符合預測意圖的內容」。
28.3 Recruitment Platforms(招聘平台)
| 角色 | 做什麼 |
|---|---|
| Predictive AI | scores candidates based on historical hiring data |
| Generative AI | drafts personalized outreach messages |
| Hybrid AI | improves hiring efficiency and candidate engagement |
28.4 三個案例的共同結構(必背)
| 步驟 | 誰做 | 產出 |
|---|---|---|
| ① 判斷 | Predictive AI | 風險/需求/分數 |
| ② 產出 | Generative AI | 摘要/文案/訊息 |
| ③ 整合與把關 | Hybrid AI | 一致 + 可解釋(必要時交人類) |
考點:三個案例的第三步永遠是「人類把關」—— 醫療是
flag uncertain cases for doctor review、電商是aligns with predicted intent。 這個「Hybrid AI 的最終目的不是自動化,而是可解釋與可信任」是本科與 Lesson 4 的交會點。
29. RAG:檢索增強生成與 AnythingLLM
29.1 RAG 的定義(課程原文)
RAG involves preprocessing your files (e.g., .txt, .pdf, .docx) by converting them into numerical vectors using an embedding model (e.g., all-MiniLM-L6-v2). These vectors are stored in a local vector database (e.g., Chroma, LanceDB) for fast retrieval during queries.
This preprocessing is a one-time computational task (~5-15 minutes for 1GB of text on a GPU), which might feel like "training" because it prepares data for use with a language model.
The embedding model itself isn't trained or modified; it's a fixed model applied to your files. The "training" analogy comes from the computational effort to create and index the vector store, but no model weights are updated.
29.2 RAG 的四個步驟
① 檔案 .txt / .pdf / .docx
↓ 用 embedding model 轉成向量
② 向量 all-MiniLM-L6-v2(舉例)
↓ 存進向量資料庫
③ 向量庫 Chroma / LanceDB
↓ 查詢時做相似度檢索
④ 檢索 + 生成 把檢索到的段落當上下文,交給 LLM 生成答案
29.3 三個必須記住的細節
| 細節 | 說法 | 為什麼重要 |
|---|---|---|
| 嵌入模型是固定的 | "isn't trained or modified"、"a fixed model" | RAG 不訓練任何模型權重 |
| 索引是一次性成本 | "one-time computational task" | 建好之後查詢很快 |
| 效能數字 | ~5–15 分鐘 / 1 GB 文字 / GPU | 唯一具體的量化數字,容易考 |
考點(本科最愛考的一題):「RAG 算不算訓練?」 正確答案:不算。它只是「建立索引」,模型權重完全沒有被更新。 課程特別用一整段解釋這個誤解,就是因為它會被考。
29.4 課程提到的具體工具
| 類別 | 舉的例子 |
|---|---|
| 嵌入模型 | all-MiniLM-L6-v2 |
| 向量資料庫 | Chroma、LanceDB |
| 檔案格式 | .txt、.pdf、.docx |
29.5 AnythingLLM 的六步操作
下圖列出操作流程:
| # | 英文 | 中文 |
|---|---|---|
| ① | Launch AnythingLLM: and navigate to the "Documents" or "Workspaces" section | 開啟 AnythingLLM,進到 Documents/Workspaces |
| ② | Create or Select a Workspace: to organize your documents | 建立或選擇工作區 |
| ③ | Upload Your Documents: by dragging and dropping files (PDF, TXT, etc.) or using the upload button | 拖放上傳文件 |
| ④ | Move and Embed: the uploaded documents into your chosen workspace | 把文件移入工作區並嵌入 |
| ⑤ | Connect to an LLM: (like Ollama or LM Studio) and select it as your provider | 連接 LLM(Ollama/LM Studio) |
| ⑥ | Chat with Your Documents: by asking questions, and the RAG system will use the embedded vectors to find relevant information from your files to generate answers | 開始問答 |
第 ④ 步的 "Move and Embed" 就是 §29.2 的 ②③ 步——把文件轉成向量並存起來。
考點:AnythingLLM 是一個「RAG 前端」,它自己不是 LLM—— 它負責文件管理 + 向量檢索,真正的生成交給外部的 LLM(Ollama/LM Studio)。 這與 §14 的「聚合 App」是不同層次的工具:聚合 App 換的是模型,AnythingLLM 加的是你的資料。
30. LLM vs RAG:比較、強弱與使用時機
這是第 ③ 條主線的核心,也是本科最實用的一段。
30.1 五個維度的對照(對照表)
| Feature | RAG (Retrieval-Augmented Generation) | LLM (Large Language Model) |
|---|---|---|
| Knowledge Source | Internal + external retrieval | Internal (trained data) |
| Data Freshness | Can be real-time | Limited to cutoff date |
| Accuracy on niche topics | Higher, grounded in sources | May hallucinate |
| Complexity | Needs retrieval pipeline | Simpler to deploy |
| Offline Capability | No (needs data access) | Yes |
考點:Offline Capability 這一列最容易答錯——對照表寫的是 LLM: Yes/RAG: No。因為 RAG 需要「資料存取」這一環, 而純 LLM 的權重就在本機,斷網也能跑。
30.2 強項與弱項
課程把優缺點分兩欄:
| LLM | RAG | |
|---|---|---|
| Strengths | • Works offline • Fast generation • Great for creative tasks |
• Up-to-date info • Source-grounded answers • Better for compliance-critical domains |
| Weaknesses | • Outdated knowledge • Higher hallucination risk |
• More complex setup • Slightly slower |
30.3 五個情境的選擇(對照表)
| Scenario | Best Fit | Reason |
|---|---|---|
| Creative writing | LLM | No need for real-time facts |
| Customer support | RAG | Pulls latest product information |
| Medical research | RAG | Needs accurate, citable data |
| Language translation | LLM | Relies on learned patterns |
| Legal Consultation | RAG | Must reference current laws |
30.4 判斷的兩條規則(背這兩個就夠)
| 情境特徵 | 選 |
|---|---|
| 需要即時/最新資訊 | RAG |
| 需要可引用來源 | RAG |
| 需要法規遵循(compliance) | RAG |
| 需要創造性(寫作、翻譯) | LLM |
| 需要離線 | LLM |
| 需要速度 | LLM |
考點:Language translation → LLM 是本表裡最反直覺的一格 (你可能會以為翻譯需要查字典,但理由是「relies on learned patterns」)。 另外 Medical research → RAG 的理由是 citable(可引用),不是「比較準」。
30.5 本機實測:親手做一次最小的 RAG
本課的 Lab LLM/RAG.ipynb 就是一個不依賴任何向量資料庫的極簡 RAG。
本機實測(transformers 5.17.0/RTX 4090,用 sample.txt):
import os, sys
sys.path.insert(0, "_shim")
import numpy as np, torch
from transformers import AutoModel, AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("distilbert-base-uncased")
emb_model = AutoModel.from_pretrained("distilbert-base-uncased")
tok_g = AutoTokenizer.from_pretrained("distilgpt2")
gen = AutoModelForCausalLM.from_pretrained("distilgpt2")
gen.config.pad_token_id = gen.config.eos_token_id
def split_document(text, chunk_size=100): # 切塊:每 100 個「字」
words = text.split()
return [" ".join(words[i:i+chunk_size]) for i in range(0, len(words), chunk_size)]
def get_embedding(text): # 嵌入:取最後一層的「平均池化」
inputs = tok(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
with torch.no_grad():
return emb_model(**inputs).last_hidden_state.mean(dim=1).squeeze().numpy()
chunks = split_document(open("sample.txt", encoding="utf-8").read())
emb = np.array([get_embedding(c) for c in chunks])
q = get_embedding("What is a curious robot?") # 檢索
sims = np.dot(emb, q) / (np.linalg.norm(emb, axis=1) * np.linalg.norm(q))
top = sims.argsort()[-2:][::-1]
prompt = "Question: What is a curious robot?\nContext: %s\nAnswer:" % \
" ".join(chunks[i] for i in top)
本機實測輸出:
chunks = 2 | 總字數 = 110
chunk 0: Artificial intelligence is transforming how people learn, wo...
chunk 1: curious robots during STEM workshops to help students brains...
embedding shape = (2, 768) | 0.04 s
similarities = [0.6573 0.7357]
top-k index = [1, 0]
prompt 字元數 = 863 | prompt token 數 = 153
30.6 ⚠️ 最重要的發現:這支 notebook 有一個真實缺陷
課程 RAG.ipynb 最後是這樣生成答案的:
result = generator(prompt, max_length=50, num_return_sequences=1,
temperature=0.7, truncation=True) # ← 舊寫法
本機實測直接重現了錯誤:
[重現課程問題] ValueError: Input length of input_ids is 153, but `max_length` is set to 50.
為什麼會爆:max_length 在現代 transformers 裡是「輸入 + 輸出的總長度上限」,
但上面的 prompt 光是問題 + 2 個 chunk 就已經是 153 個 token,早就超過 50。
| 寫法 | 意思 | 結果 |
|---|---|---|
max_length=50 |
總長度 ≤ 50 | ❌ prompt 153 token → ValueError |
max_new_tokens=50 |
再生成 ≤ 50 | ✅ 正常運作 |
正確寫法:
out = gen.generate(**enc, max_new_tokens=50, do_sample=True,
temperature=0.7, top_k=50, pad_token_id=gen.config.pad_token_id)
30.7 修好之後:檢索對了,生成卻不聽話
改用 max_new_tokens=50 之後的真實輸出:
=== RAG answer, max_new_tokens=50 (0.45 s) ===
Question: What is a curious robot?
Context: curious robots during STEM workshops to help students brainstorm ideas.
Artificial intelligence is transforming how people learn, work, and solve
problems in everyday life. ... A curious robot is a special type of
educational robot designed to explore, observe, and learn alongside students.
... Teachers often use
Answer: a curious robot.
Context: curious robots at a STEM workshop to help students brainstorm ideas.
Artificial intelligence is transforming how people learn, work, and solve
problems in everyday life. ...
兩個觀察,都是本科最值錢的結論:
- 檢索是對的:
similarities = [0.6573, 0.7357],chunk 1(真的在定義 curious robot 的那一段) 分數較高,被排在第一位。向量檢索在只有 2 塊文件時完美運作。 - 生成是錯的:模型沒有回答問題,而是把 prompt 抄回來。
原因是
distilgpt2(81.9 M 參數)沒有經過指令微調—— 它只會「接龍」,不會「回答」(見 §5.6 的同一個結論)。
考點:這正好驗證 §30.1 表格的第一列—— RAG 解決的是「知識來源」,不解決「模型會不會聽話」。 換句話說:RAG ≠ 讓模型變聰明,它只是把對的資料放到模型面前。 若模型太弱(如
distilgpt2),即使檢索完全正確,答案依然不能用。
31. 更多 ChatGPT:Hinton 的推理題
課程是整份筆記唯一的哲學討論,但因為情境鮮明,很容易出題。
31.1 完整敘述
In this talk (https://youtu.be/sitHS6UDMJc at 13:55) Geoffrey Hinton (Nobel prize winner – Godfather of AI) gives an example of the basic reasoning GPT-4 can do. He asks GPT-4:
'I want all the rooms in my house to be white, at present there are some white rooms, some blue rooms and some yellow rooms and yellow paint faints to white within a year. So what should I do if I want all the rooms to be white within 2 years?'
The answer GPT-4 gave was: 'You should paint the blue rooms yellow.'
Does this answer disprove the statement that LLM's are just stochastic parrots?
31.2 這題的推理鏈(為什麼「漆成黃色」是對的)
| 現況 | 目標 | 策略 |
|---|---|---|
| 白房間 | 白 | 不用動 |
| 藍房間 | 白 | 直接漆白要等?不行——藍漆成黃,一年後自動變白 |
| 黃房間 | 白 | 放著等一年就會自己變白 |
GPT-4 必須同時掌握三件事才答得出來:
- 黃漆一年會褪成白(題目給的規則)
- 藍漆成黃,就搭上「一年褪白」這條規則
- 目標期限是 2 年,所以有足夠時間走兩段
31.3 「stochastic parrot(隨機鸚鵡)」是什麼
| 說法 | 主張 |
|---|---|
| Stochastic parrot | LLM 只是統計式模仿,不理解語意,只是在預測下一個詞 |
| Hinton 的立場 | 這題顯示 GPT-4 做了多步規劃(planning),不只是模仿 |
考點:課程沒有給答案,而是留了一個問句。 考試若出這題,重點是能複述這個例子與兩個立場,而不是選邊站。 要記住的專有名詞是 "stochastic parrots"。
31.4 這一頁在課程中的位置
它是「Popular LLM」這條主線的收尾——從「有哪些產品」講到「這些模型到底懂不懂」。 接著 §32 就把焦點轉回程式實作。
32. 程式範例索引與本機實測總表
程式範例索引(Large Language Model — Code Example of LLM and RAG)。
LLM.ipynb(文字)、RAG.ipynb(檢索+生成)、Predictive AI.ipynb(數字)、Gen AI.ipynb(圖片)。|Qwen-Image 2.1 生成插圖課程把四支 Lab 分成兩組指派:
| 指令 | Lab 檔案 |
|---|---|
| • Refer to the Predictive AI.ipynb • Refer to the Gen AI.ipynb |
GenAI/Predictive AI.ipynb、GenAI/Gen AI.ipynb |
| • Refer to LLM.ipynb • Refer to RAG.ipynb |
LLM/LLM.ipynb、LLM/RAG.ipynb |
32.1 四支 Lab 的對應關係
| Lab | 對應章節 | 用到什麼 | 產出什麼 |
|---|---|---|---|
Predictive AI.ipynb |
§17–§18 | scikit-learn LinearRegression |
房價預測(數字) |
Gen AI.ipynb |
§19–§20、§25 | diffusers StableDiffusionPipeline |
圖片 |
LLM.ipynb |
§4–§5 | transformers distilgpt2 |
文字 |
RAG.ipynb |
§29–§30 | distilbert 嵌入 + distilgpt2 生成 | 有檢索的文字 |
32.2 四支 Lab 的共同設計(教學意圖)
| 共同點 | 說明 |
|---|---|
| 都用免費、免 token 的模型 | distilgpt2、distilbert-base-uncased、stable-diffusion-v1-5 |
| 都在 Colab 可跑 | 不需本機 GPU |
| 都用 ipywidgets 做互動 | prompt 輸入框、滑桿、按鈕 |
| 都包了 try/except | print(f"Error: {str(e)}") |
32.3 本機實測總表(真實數據)
| 項目 | 數值 | 出處 |
|---|---|---|
| Python | 3.11.15 | 環境 |
| torch | 2.14.1+cu132 | 環境 |
| transformers | 5.17.0 | 環境 |
| GPU | NVIDIA GeForce RTX 4090(24.0 GB) | 環境 |
distilgpt2 參數量 |
81.9 M | §5.6 |
distilgpt2 載入時間 |
15.15 s(首次) | §5.6 |
| 文字生成(temp 0.7) | 0.18 s / 10 tokens | §5.6 |
| 文字生成(temp 1.5) | 0.36 s / 40 tokens | §5.6 |
| 文字生成(3 個序列) | 0.47 s | §5.6 |
| SD 1.5 U-Net 參數量 | 859.5 M | §20.4 |
| SD 1.5 載入時間 | 7.24 s | §20.4 |
| SD 生成(512×512,20 步) | 0.61 s | §20.4 |
| SD 峰值 VRAM | 5.13 GB | §20.4 |
| RAG 嵌入維度 | 768(distilbert-base) | §30.5 |
| RAG chunk 數 | 2(110 字 / 100) | §30.5 |
| RAG 檢索相似度 | 0.6573 / 0.7357 | §30.5 |
| RAG prompt token 數 | 153 | §30.5 |
| RAG 生成時間 | 0.45 s | §30.7 |
| 房價預測 MAE | $11,227.31(seed=42) | §18.3 |
| 房價預測 R² | 1.00 | §18.3 |
32.4 四支 Lab 在本機跑不起來的三個原因(實測記錄)
| 問題 | 錯誤訊息 | 解法 |
|---|---|---|
pipeline 無法匯入 |
ModuleNotFoundError: Could not import module 'pipeline' |
見附錄 B:本機 torchaudio 的 CUDA 版本問題 |
ipywidgets 未安裝 |
無(Colab 內建) | 本機可移除互動層,直接跑核心 |
| RAG 生成直接爆 | ValueError: Input length of input_ids is 153, but max_length is set to 50 |
改用 max_new_tokens(見 §30.6) |
考點:Lab 是為 Google Colab 寫的。考題若問「這些 notebook 預期在哪裡執行」, 答案線索是
from google.colab import files(RAG.ipynb)與!pip install——Colab 環境。
33. 考試重點整理
33.1 必背十條
| # | 重點 | 一句話 |
|---|---|---|
| 1 | 生成式 AI 的定義 | create new content by learning patterns from existing data |
| 2 | 三大主題 | Popular LLM/Predictive vs Generative AI/LLM vs RAG |
| 3 | 六個產品與開發者 | ChatGPT=OpenAI、Gemini=Google、Copilot=Microsoft、Llama=Meta、Grok=xAI、Perplexity=AI Search Engine |
| 4 | GPT 的展開 | Generative Pre-trained Transformer |
| 5 | RLHF 三階段 | SFT → Reward Model → PPO |
| 6 | AI ⊃ ML ⊃ DL ⊃ Generative AI | 四層包含順序 |
| 7 | GAN 的兩個網路 | Generator(造假)/Discriminator(辨真),零和對抗 |
| 8 | Diffusion 的兩個過程 | Forward 加噪 → Reverse 去噪(只有 Reverse 要訓練) |
| 9 | RAG 不是訓練 | 只建索引,模型權重不變 |
| 10 | LLM vs RAG 的離線能力 | LLM: Yes/RAG: No |
33.2 最容易混淆的五組
| # | 混淆點 | 正確答案 |
|---|---|---|
| 1 | GAN 訓練成功的標準 | 判別器準確率降到 50%(不是越高越好) |
| 2 | GAN 訓練太久 | 會因 junk feedback 而崩壞(不是過擬合) |
| 3 | DALL·E / Stable Diffusion 屬於 | Diffusion(不是 GAN) |
| 4 | DDIM 是什麼 | DDPM 的加速取樣器(不是新架構) |
| 5 | 翻譯為什麼選 LLM | 因為 relies on learned patterns(不是因為不用查資料) |
33.3 三個版本落差(本機實測)
| # | 舊寫法 | 現況 |
|---|---|---|
| 1 | generator(prompt, max_length=50, ...) |
在 transformers 5.17.0 會丟 ValueError,要改 max_new_tokens=50 |
| 2 | 「may take 30-60 seconds」(SD 生成) | 在 RTX 4090 上只要 0.6–0.8 秒(數字來自 Colab T4) |
| 3 | from transformers import pipeline |
本機因 torchaudio/torch 的 CUDA 版本不一致而無法匯入(見附錄 B) |
33.4 五個「一定會考」的數字
| 數字 | 意義 |
|---|---|
| 7.5 | Stable Diffusion 的 guidance_scale 預設值 |
| 20 | Stable Diffusion 的 num_inference_steps 預設值 |
| 50% | GAN 收斂時判別器的準確率 |
| 5–15 分鐘 / 1 GB | RAG 建立索引的效能(GPU) |
| 768 | distilbert-base-uncased 的嵌入維度 |
附錄 A:名詞與架構速查表
A.1 生成式 AI 的核心名詞
| 名詞 | 全稱 | 一句話 |
|---|---|---|
| Generative AI | — | 創造新內容(文字/圖/音/影片/程式碼) |
| Predictive AI | — | 預測未來結果(數值/類別) |
| LLM | Large Language Model | 用深度學習 + 超大資料集處理文字 |
| AIGC | AI-Generated Content | AI 完全生成的內容 |
| PGC | Professionally-created Content | 專業生產內容 |
| UGC | User-generated Content | 使用者生成內容 |
| RLHF | Reinforcement Learning from Human Feedback | 用人類回饋做強化學習 |
| SFT | Supervised Fine-Tuning | 監督式微調 |
| PPO | Proximal Policy Optimization | 近端策略優化 |
| RAG | Retrieval-Augmented Generation | 檢索增強生成 |
| Hybrid AI | — | 混合式 AI(預測+生成,或符號+次符號) |
A.2 生成模型四大家族
| 模型 | 全稱 | 機制 | 生成方式 |
|---|---|---|---|
| GAN | Generative Adversarial Network | 生成器 vs 判別器,零和對抗 | 一次前向 |
| VAE | Variational Autoencoder | 神經網路 + 貝氏推論學潛在表徵 | 一次解碼 |
| Diffusion | Diffusion Model | 加噪 → 去噪 | 迭代數十步 |
| AR | Autoregressive Model | X_t = f(X_{t-1}, …) | 逐個 token |
A.3 Diffusion 相關
| 名詞 | 全稱 | 一句話 |
|---|---|---|
| Forward Process | — | 逐步加高斯雜訊直到變純雜訊 |
| Reverse Process | — | 逐步去噪還原(要訓練的部分) |
| SDE | Stochastic Differential Equation | 描述連續時間的加噪過程 |
| DDPM | Denoising Diffusion Probabilistic Model | 機率式去噪,慢但品質高 |
| DDIM | Denoising Diffusion Implicit Model | 加速取樣器,可跳步 |
A.4 預測式 AI 的演算法
| 演算法 | 英文 | 用途 |
|---|---|---|
| 迴歸 | Regression | 連續數值 |
| 決策樹 | Decision Tree | 可解釋的分類/回歸 |
| 隨機森林 | Random Forest | 多棵樹投票 |
| 神經網路 | Neural Network | 非線性關係 |
| 集成方法 | Ensemble | 多模型合成 |
A.5 產品與開發者對照
| 產品 | 開發者 | 類別 |
|---|---|---|
| ChatGPT | OpenAI | 通用對話 |
| Gemini / Bard | 通用對話 | |
| Copilot | Microsoft | 綁生態的助手 |
| Llama | Meta(Facebook) | 開放權重 |
| Grok | xAI(Elon Musk) | 綁 X 平台 |
| Perplexity | Perplexity AI | AI 搜尋引擎 |
| Kimi | Moonshot AI | 長上下文對話 |
| Tongyi(通義千問 Qwen) | Alibaba | 模型家族 |
| DeepSeek | DeepSeek | 開放權重、可本機跑 |
A.6 Lab 用到的模型
| 模型 | 用途 | 大小 | 備註 |
|---|---|---|---|
distilgpt2 |
文字生成 | 81.9 M | GPT-2 的蒸餾版,免 token |
distilbert-base-uncased |
句子嵌入 | 768 維 | RAG.ipynb 用來檢索 |
all-MiniLM-L6-v2 |
句子嵌入 | 384 維 | 舉例用 |
runwayml/stable-diffusion-v1-5 |
影像生成 | 859.5 M(U-Net) | 512×512 |
附錄 B:常見錯誤與陷阱
B.1 十大陷阱總表
| # | 陷阱 | 錯誤寫法 | 正確寫法 |
|---|---|---|---|
| 1 | max_length 是總長度 |
generate(max_length=50) 而 prompt 已 153 token |
generate(max_new_tokens=50) |
| 2 | temperature 開太大 |
temperature=1.5 期待更好的答案 |
0.7 一般;需要穩定用 0.1–0.3 |
| 3 | 以為 GAN 訓練越久越好 | 一直訓練到判別器 100% 準 | 判別器降到 50% 即應停止 |
| 4 | 把 GAN 的判別器準確率當越高越好 | 「判別器 100% 準 = 訓練成功」 | 那代表生成器完全失敗 |
| 5 | float32 跑 SD |
pipe.to("cuda") 不指定 dtype |
.to(dtype=torch.float16)(省一半 VRAM) |
| 6 | 忘了 pad_token_id |
distilgpt2 直接生成 → 警告 |
model.config.pad_token_id = model.config.eos_token_id |
| 7 | 以為 RAG 會訓練模型 | 「RAG 是把模型微調到你的資料上」 | RAG 只建索引,權重不變 |
| 8 | 以為 RAG 需要連網 | 「RAG 是離線方案」 | 課程寫 RAG: No/LLM: Yes(離線能力) |
| 9 | 把 R²=1.00 當成模型很好 |
「R² 接近 1 所以模型最棒」 | 因為資料是線性公式生成的 |
| 10 | guidance_scale 調太高 |
guidance_scale=20 追求品質 |
預設 7.5;太高會出現過飽和/失真 |
B.2 錯誤訊息對照表
| 錯誤訊息 | 原因 | 解法 |
|---|---|---|
ValueError: Input length of input_ids is 153, but max_length is set to 50 |
用了 max_length 且 prompt 比它長 |
改 max_new_tokens=50 |
ModuleNotFoundError: Could not import module 'pipeline' |
transformers 5.17.0 的 pipeline 會連帶 import torchaudio,而本機 torchaudio(CUDA 13.0) ≠ torch(CUDA 13.2) |
見 B.3 |
RuntimeError: Detected that PyTorch and TorchAudio were compiled with different CUDA versions |
同上(根本原因) | 見 B.3 |
DistilBertModel LOAD REPORT ... UNEXPECTED: vocab_transform.bias ... |
載入 distilbert-base-uncased 時,MLM 頭的權重不屬於 AutoModel(base) |
可忽略(用法正確) |
bitsandbytes library load error: ... libbitsandbytes_cuda132.dll |
bitsandbytes 沒有對應 CUDA 13.2 的預編譯檔 | 本 Lab 不需要 bitsandbytes,可忽略 |
| 生成結果重複空白行、出現網頁殘留文字 | temperature 太高(如 1.5)或模型太小 |
降溫;換更大的模型 |
| RAG 生成的答案只是把 prompt 抄回來 | 模型(distilgpt2)沒有指令微調 |
這是預期行為,不是 bug |
B.3 本機環境的 torchaudio 問題(實測記錄)
症狀:連 from transformers import pipeline 都失敗,錯誤訊息卻指向 torchaudio。
RuntimeError: Detected that PyTorch and TorchAudio were compiled with different CUDA versions.
PyTorch has CUDA version 13.2 whereas TorchAudio has CUDA version 13.0.
根因鏈(實測追出來的完整路徑):
為什麼會影響「純文字模型」:因為 audio_utils.py 是被 processing_utils.py
間接匯入的,而幾乎所有模型都會經過它——所以連 GPT-2 都載不進來。
三種解法(本筆記採用第 3 種,不動你的環境):
| 解法 | 做法 | 評價 |
|---|---|---|
| ① 換成相符的 torchaudio | 安裝與 torch 同 CUDA 版本的 torchaudio | 最乾淨,但要找到對應 wheel |
| ② 移除 torchaudio | pip uninstall torchaudio |
有效,但會動到全域環境 |
| ③ 空替身模組 | 建 _shim/torchaudio/__init__.py,在腳本裡 sys.path.insert(0, "_shim") |
✅ 不動環境、可攜、純文字任務完全安全 |
第 ③ 種的完整內容只有一行版本號:
# _shim/torchaudio/__init__.py
__version__ = "0.0.0-shim"
使用方式(放在所有 import torch/import transformers 之前):
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "_shim"))
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer # 這樣就通了
考點:這不是本科考題,但它是「依賴地獄」的教科書級案例—— 一個你完全沒用到的套件(音訊),可以讓整個套件生態系無法匯入。 這也是為什麼實務上要用
uv/conda的隔離環境。
附錄 C:離線執行/安裝提示
C.1 這份筆記本身
單一 HTML 檔、零外部資源:所有 CSS、語法高亮、圖片都以 base64 內嵌, 下載後雙擊即可離線閱讀,不需要網路。
C.2 要自己跑 Lab 需要什麼
| 需求 | 說明 |
|---|---|
| Python | 3.11(本筆記實測版本 3.11.15) |
| PyTorch | pip install torch(本機 2.14.1+cu132,有 CUDA 更好) |
| Transformers | pip install transformers(本機 5.17.0) |
| Diffusers | pip install diffusers accelerate safetensors(SD 用) |
| scikit-learn / pandas | pip install scikit-learn pandas matplotlib seaborn |
| GPU | 非必需,但 SD 生成會從 0.6 秒變成數分鐘 |
C.3 完全離線的做法(先在有網路時把模型抓好)
# 第一次(有網路):把權重抓進本機快取
from transformers import AutoModelForCausalLM, AutoTokenizer
AutoTokenizer.from_pretrained("distilgpt2")
AutoModelForCausalLM.from_pretrained("distilgpt2")
之後把環境變數設成離線模式,就不會再連網:
$env:HF_HUB_OFFLINE='1' # 只用本機快取,不連 HuggingFace
模型快取位置:
C:\Users\<你>\.cache\huggingface\hub\
C.4 本機測試資料(不需要下載任何檔案)
RAG.ipynb 用上傳檔案,本筆記的實測改用 Lab 附的 sample.txt(110 字)。
若手上沒有它,任何一段英文文章都可以取代——RAG 的檢索品質與文件量成正比,
2 塊文件時相似度差異會很明顯。
C.5 需要網路的只有兩件事
| 動作 | 需要網路嗎 |
|---|---|
| 下載模型權重(第一次) | ✅ 要 |
| 之後的推論與生成 | ❌ 不用 |
| 閱讀本筆記 | ❌ 不用 |
| 做互動測驗 | ❌ 不用 |
附錄 D:一頁精華(考前 10 分鐘)
【三大主題】Popular LLM / Predictive AI vs Generative AI / LLM vs RAG
【產品與開發者】
ChatGPT → OpenAI 通用對話
Gemini/Bard→ Google 通用對話(原生多模態)
Copilot → Microsoft 綁生態的助手(模型來自 OpenAI)
Llama → Meta 開放權重
Grok → xAI 綁 X 平台
Perplexity → Perplexity AI AI 搜尋引擎
Kimi → Moonshot AI 長上下文
Tongyi → Alibaba 通義千問 Qwen
DeepSeek → DeepSeek 開放權重、可本機跑
【ChatGPT 的三個字母】G=Generative P=Pre-trained T=Transformer
【RLHF 三階段】SFT(人類示範)→ Reward Model(人類排序)→ PPO(重複數次)
【四層包含】AI ⊃ ML ⊃ DL ⊃ Generative AI
【內容三類】PGC(專業)/UGC(使用者)/AIGC(AI)
【Predictive 五步】蒐集 → 前處理 → 訓練 → 預測與驗證 → 部署
【GAN】
Generator 造假 / Discriminator 辨真 / 零和對抗
判別器準確率 → 50% = 收斂成功
繼續訓練過頭 = junk feedback → 崩壞
損失函數衡量「兩個分布的距離」
【Diffusion】
Forward 加噪(不用訓練)→ Reverse 去噪(要訓練)
DDPM 慢而準 / DDIM 是加速取樣器
SD 預設:num_inference_steps=20、guidance_scale=7.5、512×512
【四種生成模型】
GAN 一次前向 / VAE 一次解碼 / Diffusion 迭代去噪 / AR 逐個 token
【LLM vs RAG】
LLM:內部知識、可離線、快、會幻覺、有 cutoff date
RAG:內外檢索、即時、可引用、較複雜、不能離線
RAG 不訓練模型!只建索引(~5–15 分鐘 / 1 GB / GPU)
【五個必記數字】7.5 / 20 / 50% / 5–15 分鐘 / 768
【兩個實作陷阱(本機實測)】
① max_length=50 + 153 token prompt → ValueError(改 max_new_tokens)
② torchaudio(CUDA 13.0) ≠ torch(CUDA 13.2) → 連 pipeline 都匯入不了
附錄 E:互動式線上測驗(60 題)
60 題單選、滿分 60 分、建議 75 分鐘。 測驗以互動網頁形式提供(點選即時計分、進度自動儲存);本筆記不重複收錄題目。
E.1 開始測驗
線上版功能:
- 點選答案即自動計分,並即時顯示得分
- 作答進度自動存在你的瀏覽器(localStorage)——關掉網頁、隔天再開都能繼續
- 可切換「只顯示未答」或「只顯示答錯」的題目,快速複習
- 按「顯示答案」才揭曉正解與解析,不會一開始就被暴雷
- 需要紙本時,直接在該頁按列印即可
E.2 時間分配建議
| 階段 | 時間 | 做什麼 |
|---|---|---|
| 第一輪 | 0–40 分鐘 | 快速作答有把握的題目,不確定先標記跳過 |
| 第二輪 | 40–65 分鐘 | 回頭處理標記的難題 |
| 第三輪 | 65–75 分鐘 | 檢查有沒有漏答 |
E.3 評分參考
| 分數 | 程度 | 建議 |
|---|---|---|
| 54–60 | 優異 | 直接看附錄 D 一頁精華即可上場 |
| 45–53 | 良好 | 複習錯題所屬章節 |
| 36–44 | 及格邊緣 | 重讀主要章節 + 附錄 A |
| 0–35 | 需加強 | 整份筆記重讀一遍,再重做本卷 |
答錯的題目請對照下方〈附錄 F:互動測驗答錯題目 → 複習章節對照〉回到對應章節複習。
附錄 F:互動測驗答錯題目 → 複習章節對照
| 答錯題號 | 建議複習章節 |
|---|---|
| 1–4 | §2 生成式 AI 的定義、§1 三大主題 |
| 5–8 | §3 熱門 LLM 總覽、與 Google 搜尋的差別 |
| 9–12 | §4 ChatGPT 介面、§5 RLHF 與 LLM 定義 |
| 13–16 | §5 RLHF 三階段、PPO、獎勵模型 |
| 17–20 | §6 Gemini、§7 Prompt、§8 Copilot |
| 21–24 | §9 Llama 開放權重、§10 Grok、§11 Perplexity |
| 25–28 | §12 中國 LLM、§13 本機跑 DeepSeek |
| 29–32 | §14 聚合 App、§15 AI 偵測器 |
| 33–36 | §16 主題地圖、§17 Predictive AI 演算法 |
| 37–40 | §18 Predictive AI 五步流程、R² 的意義 |
| 41–44 | §19 生成式 AI 核心技術、§20 運作方式 |
| 45–48 | §20 SD 參數、§21 對照總表 |
| 49–52 | §22 AI/ML/DL/AIGC、§23 GAN 基礎 |
| 53–56 | §24 GAN 訓練機制、收斂與崩壞 |
| 57–60 | §25 Diffusion、§26 GAN vs Diffusion、§29–§30 RAG |
本篇為個人學習筆記整理。