# 20 AI Concepts You Must Understand in 2026
**作者**: Rahul
**日期**: 2026-05-22T08:30:43.000Z
**来源**: [https://x.com/sairahul1/status/2057740928908161461](https://x.com/sairahul1/status/2057740928908161461)
---

Everyone uses AI.
Almost nobody understands how it actually works.
People throw around words like transformers, embeddings, RAG, agents, RLHF…
…as if everyone already knows.
Most don't.
And honestly?
AI is not that complicated once you see the mental models.
ChatGPT. Claude. Midjourney. Cursor. Coding agents.
They all make sense once you understand the 20 ideas below.
No PhD required. No jargon. Just simple explanations and visuals.
Save this. You will use it again.
## PART 1: HOW AI ACTUALLY WORKS (The foundation everything is built on)
1. Neural Networks

The brain of every AI model.
A neural network is a pipeline of layers.
→ Data enters the input layer → Passes through hidden layers → Exits as a prediction
Each connection has a "weight" — a tiny score that controls how much influence one neuron has on the next.
Training = adjusting billions of these weights until the output is accurate.
Simple idea. Insane at scale.
GPT-4 has ~1.8 trillion parameters. Claude 3 Opus has hundreds of billions.
All from the same basic concept: layered neurons with adjustable connections.
## 2. Tokenization

Before AI reads your text, it breaks it into pieces called tokens.
Not always full words.
"playing" → "play" + "ing" "ChatGPT" → "Chat" + "G" + "PT" "dog" → "dog" (stays whole)
Why not just use full words?
Language is messy. New words. Typos. Mixed languages. A fixed vocabulary of words would be impossibly large.
Tokens are reusable building blocks.
Even if the model has never seen a word, it can understand it by breaking it into familiar pieces.
Rough rule: 1 token ≈ 0.75 words.
1000 tokens ≈ 750 words.
## 3. Embeddings

Once text is tokenized, each token becomes a number.
That number is an embedding — a vector that represents meaning.
Think of it as Google Maps for words.
→ "Doctor" and "Nurse" sit close together → "Doctor" and "Pizza" sit far apart → "King" minus "Man" plus "Woman" ≈ "Queen"
The model doesn't understand words like you do.
It understands distance and direction.
This is what powers: → Semantic search → Recommendations → RAG systems
Everything that "understands intent" uses embeddings under the hood.
## 4. Attention

The word "Apple" means different things:
→ "I ate an Apple" → fruit → "I bought Apple stock" → company
Embeddings alone can't solve this.
Attention can.
Attention lets every word look at every other word in a sentence and decide what matters.
In "She bought shares in Apple": → "Apple" pays high attention to "shares" and "bought" → Model concludes: company, not fruit
Before attention, models read left-to-right. Slow. Limited.
After attention, models see the whole sentence at once.
This single idea unlocked modern AI.
## 5. Transformers

The architecture powering almost every AI model today.
Introduced in 2017 in a paper called "Attention Is All You Need."
The breakthrough: instead of reading text one word at a time, process everything in parallel using attention.
How it works: → Text → Tokens → Embeddings → Stacked attention layers → Output
Each layer refines understanding: → Early layers: grammar, basic structure → Middle layers: word relationships → Deep layers: complex reasoning
The result: massively faster training and far better outputs.
GPT. Claude. Gemini. Llama. Mistral.
All transformers.
If you understand this one architecture, you understand modern AI.
## PART 2: HOW LLMs WORK (What's actually happening when you chat with AI)
## 6. LLMs (Large Language Models)

An LLM is a transformer trained on a massive amount of text.
Books. Websites. Code. Wikipedia. Reddit.
Trillions of tokens.
The training task sounds too simple to be powerful:
→ Predict the next token.
That's it.
But when you repeat this across trillions of examples, something remarkable happens.
The model learns grammar. Then reasoning. Then how to write code, translate languages, solve math problems.
No one told it to do any of that.
It emerged from next-token prediction at scale.
"Large" = hundreds of billions of parameters. Training cost = millions of dollars.
ChatGPT, Claude, Gemini → all LLMs.
## 7. Context Window

Every AI model has a memory limit.
It's called the context window.
It's the maximum number of tokens the model can "see" at once — your message + its response + conversation history.
Early GPT: ~4,000 tokens. GPT-4: 128,000 tokens. Claude 3.5: 200,000 tokens. Gemini 1.5 Pro: 1,000,000 tokens.
Bigger window = more context = better answers.
But there's a catch.
Models don't read everything equally.
They focus on the beginning and end of the context.
The middle? Often ignored.
This is called the "Lost in the Middle" problem.
Big context window ≠ perfect memory.
Understanding this explains why AI sometimes "forgets" something you clearly mentioned.
## 8. Temperature

When AI generates text, it doesn't just pick the most likely next word every time.
It has a dial called temperature.
→ Temperature = 0: always picks the safest, most predictable word → Temperature = 1: picks more creatively, more variety → Temperature = 2+: gets wild, sometimes incoherent
Low temperature → use for: code, facts, summaries High temperature → use for: brainstorming, creative writing, variations
Most tools set this for you automatically.
But understanding it explains why sometimes AI seems "boring" and sometimes it surprises you.
## 9. Hallucination

AI lies with confidence.
Not on purpose. It literally cannot help it.
Here's why.
An LLM doesn't search for truth.
It predicts what the most probable next token is.
If a false statement looks like something that "should come next" based on training patterns, it generates it.
No verification. No lookup. Pure pattern matching.
So it will: → Cite a research paper that doesn't exist → Invent an API function that was never created → State a fake historical "fact" with complete confidence
This is called hallucination.
The fix: never trust AI output on facts without verifying.
Use RAG (concept 16) to ground it in real data.
## 10. Prompt Engineering

The way you ask changes everything.
Same model. Same question. Wildly different results based on how you frame it.
Bad prompt: → "Explain APIs" → Gets: vague, surface-level answer
Good prompt: → "Explain how REST APIs handle authentication. Give a real example with code. Assume I'm a junior developer." → Gets: specific, structured, immediately useful
Prompt engineering is just clear communication.
The tricks that actually work: → Give context ("I'm building a SaaS for X") → Assign a role ("Act as a senior backend engineer") → Show examples ("Here's a format I like: ___") → Be specific about output ("Give me 5 options as a numbered list") → Break complex asks into steps
Prompt engineering isn't a hack.
It's the main way you communicate with the model.
## PART 3: HOW AI MODELS IMPROVE (How raw models become useful products)
## 11. Transfer Learning

Training from scratch is expensive.
Insane amounts of data. Massive compute. Weeks of training.
Transfer learning solves this.
You take a model already trained on a huge general task and adapt it for something specific.
You're not starting from zero. You're building on top.
Think of it like this:
→ You already know how to ride a bike → Learning a motorcycle is much faster because of that → You transfer what you already know
This is how almost all AI products work today:
→ OpenAI trains massive foundation model → Companies fine-tune it for their specific use case → Saves millions in compute and months of training
No company trains from scratch anymore.
## 12. Fine-Tuning

Transfer learning tells you the concept.
Fine-tuning is how you do it.
You take a pretrained model and continue training it on a smaller, focused dataset.
The model already speaks "language."
Now you're teaching it your specific domain.
Examples: → Medical model fine-tuned on clinical notes → Legal model fine-tuned on contracts → Coding model fine-tuned on GitHub
The result: a model that responds perfectly for your use case.
The cost: you need to update billions of parameters.
That requires serious compute — multiple GPUs, serious infrastructure.
(This is why LoRA, the next concept, matters so much.)
## 13. RLHF (Reinforcement Learning from Human Feedback)

Fine-tuning makes models specialized.
RLHF is what makes them feel helpful and safe.
Without it: the model just predicts text. Fluent, but not aligned.
With it: the model learns what humans actually prefer.
Here's how it works:
→ Show model a prompt → Model generates multiple responses → Humans rank the responses → Model learns to prefer what humans prefer
Repeat thousands of times.
The model builds a sense of "good answer": → Clear → Helpful → Honest → Safe
This is why ChatGPT and Claude feel like assistants — not random text generators.
Without RLHF, they'd still be impressive. But far less useful, less trustworthy, and much harder to control.
## 14. LoRA (Low-Rank Adaptation)

Fine-tuning is powerful but expensive.
Updating billions of parameters needs multiple GPUs and serious infrastructure.
LoRA solves this.
Instead of changing the whole model, LoRA:
→ Keeps the original model frozen → Adds tiny trainable layers on top → These layers are a fraction of the full model size
The insight: most fine-tuning changes are small.
You don't need to rewrite the whole model.
You just need small targeted adjustments.
Results: → Fine-tuning on a single consumer GPU: possible → Store one base model + swap different LoRA adapters: practical → Multiple specialized models without massive storage: done
LoRA is why open-source AI exploded.
Suddenly anyone could fine-tune powerful models on a laptop.
## 15. Quantization

Models are getting huge.
Running them requires serious memory and compute.
Quantization makes them smaller and cheaper to run.
How: reduce the precision of each weight.
A weight stored in full precision uses 32 bits.
Quantized to 4-bit → 8x smaller.
Crazy thing: the quality drop is often surprisingly small.
This is why you can now: → Run LLaMA on a MacBook → Run Mistral locally on a consumer GPU → Use powerful models on a phone
Without quantization, large models would stay locked in data centers.
With quantization, they run on your machine.
## PART 4: HOW REAL AI SYSTEMS ARE BUILT (What's behind the products you actually use)
## 16. RAG (Retrieval-Augmented Generation)

LLMs hallucinate because they answer from memory.
RAG fixes this by letting them look things up first.
How it works:
1. User asks a question
2. System searches a knowledge base for relevant documents
3. Those documents are passed to the model as context
4. Model answers using real information — not guesses
Think of it like:
→ Closed-book exam (no RAG): answers from memory, often wrong → Open-book exam (RAG): checks the source, far more accurate
Why it's powerful: → No retraining when your data changes — just update the documents → Model always works with current, accurate information → Reduces hallucination dramatically
Every serious AI product uses RAG.
Customer support bots. Legal tools. Medical assistants. Internal knowledge bases.
## 17. Vector Databases

RAG needs to find the right documents fast.
But how do you search millions of documents by meaning — not just keywords?
Vector databases.
Here's how they work:
1. Every document gets converted into an embedding (a vector of numbers)
2. These vectors get stored in the database
3. When a user asks a question, the question also becomes a vector
4. Database finds vectors closest to the question vector
5. Returns most semantically similar documents
Why this is better than keyword search:
→ "heart disease treatment" finds documents about "cardiac care protocols" → Even though the exact words don't match, the meaning does
Tools: Pinecone, Qdrant, Weaviate, pgvector
Vector databases are what makes AI systems "understand" — not just match strings.
## 18. AI Agents

An LLM responds to messages.
An AI agent actually does things.
The difference:
→ LLM: you ask, it answers, done → Agent: you give a goal, it plans, takes actions, checks results, adjusts, repeats
The agent loop:
Think → Act → Observe → Repeat
Example: coding agent fixing a bug → Reads the issue → Explores the codebase → Identifies the problem → Writes a fix → Runs tests → Sees what failed → Adjusts the fix → Repeats until done
The model is the brain. Tools are the hands.
What tools can agents use? → Web search → Code execution → File system → APIs → Email / calendar → Databases
Agents are what turn AI from a chatbot into a coworker.
## 19. Chain of Thought (CoT)

Sometimes AI gets the wrong answer not because it's stupid.
But because it jumped to the answer too fast.
Chain of thought fixes this.
Instead of asking for the final answer directly:
→ "Solve: If a train travels 60mph for 2.5 hours, how far?"
You prompt it to think step by step:
→ "Solve step by step: Speed = 60mph. Time = 2.5 hours. Distance = Speed × Time = ?"
The model walks through reasoning: → Step 1: Identify the formula → Step 2: Plug in numbers → Step 3: Calculate
Far more reliable for math, logic, multi-step problems.
The insight: give the model room to think, not just react.
This is why prompts like "think step by step" or "reason through this carefully" actually work.
## 20. Diffusion Models

Everything so far has been about text.
Diffusion models explain how AI generates images.
The process is counterintuitive.
The model doesn't learn to draw.
It learns to destroy images.
Training: → Start with a real image → Add noise step by step until it's pure static → Train the model to reverse this — remove noise step by step
Generation: → Start with pure noise → Model removes noise step by step → Guided by your text prompt → Image emerges from randomness
The name comes from physics — particles diffusing randomly through a medium, like ink spreading in water.
Here, the model learns to reverse that diffusion.
Not just images anymore: → Video (Sora, Runway) → Audio → 3D content → Drug molecules
Diffusion models are how AI generates anything visual.
That's all 20.
Let me recap:
How AI Works:
→ 1. Neural Networks — layered pattern learning
→ 2. Tokenization — breaking text into pieces
→ 3. Embeddings — meaning as numbers
→ 4. Attention — context changes meaning
→ 5. Transformers — the architecture behind everything
How LLMs Work:
→ 6. LLMs — next token prediction at massive scale
→ 7. Context Window — memory limits and the middle problem
→ 8. Temperature — the creativity dial
→ 9. Hallucination — confident and wrong
→ 10. Prompt Engineering — how you communicate
How Models Improve:
→ 11. Transfer Learning — build on what exists
→ 12. Fine-Tuning — specialize a model
→ 13. RLHF — teach it to be helpful
→ 14. LoRA — fine-tuning without the cost
→ 15. Quantization — run big models on small machines
How Real Systems Are Built:
→ 16. RAG — look it up first, then answer
→ 17. Vector Databases — search by meaning
→ 18. AI Agents — from answering to doing
→ 19. Chain of Thought — give it room to think
→ 20. Diffusion Models — noise to image
You now understand how AI actually works.
Most people who use AI every day don't.
That gap is your edge.
If this was useful:
→ Repost to share it with your network → Follow @sairahul1 for more breakdowns like this → Bookmark this for reference
I write about AI, building products, and systems that work while you sleep.
## 相关链接
- [Rahul](https://x.com/sairahul1)
- [@sairahul1](https://x.com/sairahul1)
- [3.4M](https://x.com/sairahul1/status/2057740928908161461/analytics)
- [@sairahul1](https://x.com/@sairahul1)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [4:30 PM · May 22, 2026](https://x.com/sairahul1/status/2057740928908161461)
- [3.4M Views](https://x.com/sairahul1/status/2057740928908161461/analytics)
- [View quotes](https://x.com/sairahul1/status/2057740928908161461/quotes)
---
*导出时间: 2026/5/23 15:11:21*
---
## 中文翻译
# 2026年你必须了解的20个AI概念
**作者**: Rahul
**日期**: 2026-05-22T08:30:43.000Z
**来源**: [https://x.com/sairahul1/status/2057740928908161461](https://x.com/sairahul1/status/2057740928908161461)
---

每个人都在使用 AI。
几乎没人真正理解它是如何工作的。
人们到处抛出诸如 Transformer、Embedding(嵌入)、RAG、Agent(代理)、RLHF(人类反馈强化学习)这样的词汇……
……就好像大家都懂一样。
大多数人并不懂。
说实话?
一旦你看清了背后的心智模型,AI 其实并不复杂。
ChatGPT。Claude。Midjourney。Cursor。编程代理。
只要理解了下面的 20 个理念,它们就都讲得通了。
不需要博士学位。没有行话。只有简单的解释和图示。
收藏这篇文章。你会用得上的。
## 第一部分:AI 究竟是如何工作的(一切构建的基础)
1. 神经网络

每个 AI 模型的大脑。
神经网络是一个由层级组成的管道。
→ 数据进入输入层 → 穿过隐藏层 → 以预测结果输出
每个连接都有一个“权重”——一个微小的分数,控制着一个神经元对下一个神经元有多大的影响力。
训练 = 调整数十亿个这样的权重,直到输出准确无误。
想法很简单。规模化后却威力惊人。
GPT-4 有约 1.8 万亿个参数。Claude 3 Opus 有数千亿个。
全都基于同一个基本概念:带有可调节连接的分层神经元。
## 2. 分词

在 AI 阅读你的文本之前,它会将其分解成称为“Token”的片段。
不一定是完整的单词。
"playing"(正在玩)→ "play" + "ing"
"ChatGPT" → "Chat" + "G" + "PT"
"dog"(狗)→ "dog"(保持完整)
为什么不直接使用完整的单词?
语言是很杂乱的。新词、错别字、混合语言。一个固定的词汇表会大得无法想象。
Token 是可复用的构建块。
即使模型从未见过某个词,它也可以通过将其分解为熟悉的片段来理解它。
粗略规则:1 个 Token ≈ 0.75 个单词。
1000 个 Token ≈ 750 个单词。
## 3. 嵌入

一旦文本被分词,每个 Token 就会变成一个数字。
这个数字就是一个嵌入——一个表示意义的向量。
把它想象成单词版的谷歌地图。
→ “医生”和“护士”挨得很近
→ “医生”和“披萨”离得很远
→ “国王”减去“男人”加上“女人” ≈ “王后”
模型并不像你那样理解单词。
它理解的是距离和方向。
这驱动了:→ 语义搜索 → 推荐系统 → RAG 系统
所有“理解意图”的东西,底层都在使用嵌入。
## 4. 注意力机制

“Apple”这个词在不同语境下有不同含义:
→ “我吃了一个 Apple” → 水果
→ “我买了 Apple 的股票” → 公司
仅靠嵌入无法解决这个问题。
注意力机制可以。
注意力机制让每个词都能审视句子中的其他词,并判断什么才是重要的。
在“她买了 Apple 的股票”中:
→ “Apple”高度关注“股票”和“买了”
→ 模型得出结论:是公司,不是水果
在注意力机制出现之前,模型从左到右阅读。慢。受限。
有了注意力机制之后,模型可以同时看到整个句子。
正是这单一概念解锁了现代 AI。
## 5. Transformer(转换器)

驱动当今几乎所有 AI 模型的架构。
2017 年在一篇名为《Attention Is All You Need》(你只需要注意力)的论文中提出。
突破点在于:不再逐词阅读文本,而是使用注意力机制并行处理所有内容。
工作原理:→ 文本 → Token → 嵌入 → 堆叠的注意力层 → 输出
每一层都在完善理解:
→ 浅层:语法、基本结构
→ 中层:词语关系
→ 深层:复杂推理
结果:训练速度大幅加快,输出质量远超从前。
GPT。Claude。Gemini。Llama。Mistral。
全都是 Transformer。
如果你理解了这一种架构,你就理解了现代 AI。
## 第二部分:大语言模型(LLM)如何工作(当你与 AI 聊天时实际发生了什么)
## 6. LLM(大语言模型)

LLM 就是在海量文本上训练出来的 Transformer。
书籍。网站。代码。维基百科。Reddit。
数万亿个 Token。
训练任务听起来简单得不可能有强大的效果:
→ 预测下一个 Token。
就这样。
但当你重复这个过程数万亿次之后,非凡的事情发生了。
模型学会了语法。然后是推理。然后是写代码、翻译语言、解决数学问题。
没人教它做这些。
它是从大规模的“下一个 Token 预测”中涌现出来的。
“大” = 数千亿个参数。训练成本 = 数百万美元。
ChatGPT、Claude、Gemini → 都是 LLM。
## 7. 上下文窗口

每个 AI 模型都有一个记忆限制。
这就是上下文窗口。
它是模型一次能“看到”的最大 Token 数量——你的消息 + 它的回复 + 对话历史。
早期的 GPT:约 4,000 个 Token。
GPT-4:128,000 个 Token。
Claude 3.5:200,000 个 Token。
Gemini 1.5 Pro:1,000,000 个 Token。
窗口越大 = 上下文越多 = 答案越好。
但有个陷阱。
模型不会平均地阅读所有内容。
它们关注上下文的**开头**和**结尾**。
中间呢?经常被忽略。
这被称为“迷失在中间”问题。
大上下文窗口 ≠ 完美记忆。
理解了这一点,你就明白为什么 AI 有时会“忘记”你明确提到过的事情。
## 8. 温度

当 AI 生成文本时,它不会每次都只选择最可能的下一个词。
它有一个叫做“温度”的旋钮。
→ 温度 = 0:总是选择最安全、最可预测的词
→ 温度 = 1:更有创意地选择,多样性更高
→ 温度 = 2+:变得狂野,有时语无伦次
低温度 → 用于:代码、事实、摘要
高温度 → 用于:头脑风暴、创意写作、生成变体
大多数工具会自动为你设置这个值。
但理解它,就能解释为什么有时 AI 看起来很“无聊”,有时却能给你惊喜。
## 9. 幻觉

AI 会自信地撒谎。
不是故意的。它真的控制不住自己。
原因如下。
LLM 并不寻找真理。
它预测的是最有可能出现的下一个 Token 是什么。
如果一个错误的陈述看起来像是基于训练模式“应该接在后面”的内容,它就会生成出来。
没有验证。没有查找。纯粹的模式匹配。
所以它会:→ 引用一篇不存在的论文 → 编造一个从未创建过的 API 函数 → 以绝对的自信陈述一个虚假的历史“事实”
这就是所谓的幻觉。
解决方法:永远不要在未经核实的情况下信任 AI 输出的事实。
使用 RAG(概念 16)将其建立在真实数据之上。
## 10. 提示词工程

提问的方式改变一切。
同一个模型。同样的问题。根据你的表述方式,结果天差地别。
糟糕的提示:
→ “解释一下 API”
→ 得到:模糊、肤浅的回答
好的提示:
→ “解释一下 REST API 如何处理身份验证。给出一个包含代码的真实示例。假设我是一名初级开发者。”
→ 得到:具体、结构化、立即可用的回答
提示词工程就是清晰的沟通。
真正有效的技巧:
→ 给出背景(“我正在为 X 构建 SaaS”)
→ 分配角色(“担任高级后端工程师”)
→ 展示示例(“这是我喜欢的格式:___”)
→ 明确输出要求(“给我 5 个选项,列成编号列表”)
→ 将复杂的请求拆解成步骤
提示词工程不是什么黑客技巧。
它是你与模型沟通的主要方式。
## 第三部分:AI 模型如何改进(原始模型如何变成有用的产品)
## 11. 迁移学习

从头训练很昂贵。
海量的数据。庞大的算力。数周的训练时间。
迁移学习解决了这个问题。
你选取一个已经在庞大通用任务上训练好的模型,并将其改编用于特定任务。
你不是从零开始。你是站在巨人的肩膀上。
可以这样理解:
→ 你已经会骑自行车
→ 学骑摩托车因此快得多
→ 你迁移了已有的知识
这就是现在几乎所有 AI 产品的工作方式:
→ OpenAI 训练大型基础模型
→ 公司针对其特定用例进行微调
→ 节省数百万算力成本和数月的训练时间
没有公司再从头训练了。
## 12. 微调

迁移学习告诉了你概念。
微调是你实现它的方法。
你选取一个预训练模型,并在一个更小、更专注的数据集上继续训练它。
模型已经会说“语言”了。
现在你在教它你的特定领域。
例如:
→ 医疗模型在临床笔记上微调
→ 法律模型在合同上微调
→ 代码模型在 GitHub 上微调
结果:一个能为你的用例完美响应的模型。
代价:你需要更新数十亿个参数。
这需要强大的算力——多个 GPU、强大的基础设施。
(这就是为什么下一个概念 LoRA 如此重要。)
## 13. RLHF(人类反馈强化学习)

微调让模型变得专业化。
RLHF 让它们变得乐于助人且安全。
没有它:模型只是预测文本。流利,但不对齐。
有了它:模型学会了人类实际上喜欢什么。
工作原理如下:
→ 给模型一个提示词
→ 模型生成多个回答
→ 人类对回答进行排序
→ 模型学习去偏好人类偏好的内容
重复数千次。
模型建立了一种“好回答”的感觉:
→ 清晰
→ 有帮助
→ 诚实
→ 安全
这就是为什么 ChatGPT 和 Claude 感觉像助手——而不是随机文本生成器。
没有 RLHF,它们仍然会令人印象深刻。但用途会少得多,可信度低得多,也难控制得多。
## 14. LoRA(低秩适应)

微调很强大,但很昂贵。
更新数十亿个参数需要多个 GPU 和强大的基础设施。
LoRA 解决了这个问题。
LoRA 不改变整个模型,而是:
→ 保持原始模型冻结
→ 在顶部添加微小的可训练层
→ 这些层只是完整模型大小的一小部分
洞察:大多数微调的改动都很小。
你不需要重写整个模型。
你只需要微小的针对性调整。
结果:
→ 在单个消费级 GPU 上微调:成为可能
→ 存储一个基础模型 + 交换不同的 LoRA 适配器:变得实际
→ 拥有多个专用模型而无需海量存储:搞定
LoRA 是开源 AI 爆发的原因。
突然间,任何人都可以在笔记本电脑上微调强大的模型。
## 15. 量化

模型变得越来越大。
运行它们需要大量内存和算力。
量化让它们变得更小、运行成本更低。
方法:降低每个权重的精度。
以全精度存储的权重使用 32 位。
量化到 4 位 → 缩小 8 倍。
疯狂的是:质量下降往往出奇地小。
这就是为什么你现在可以:
→ 在 MacBook 上运行 LLaMA
→ 在消费级 GPU 上本地运行 Mistral
→ 在手机上使用强大的模型
没有量化,大型模型将被锁在数据中心里。
有了量化,它们就能在你的机器上运行。
## 第四部分:真实的 AI 系统是如何构建的(你实际使用的产品背后是什么)
## 16. RAG(检索增强生成)

LLM 会产生幻觉,因为它们是凭记忆回答。
RAG 通过让它们先查找资料来解决这个问题。
工作原理:
1. 用户提问
2. 系统在知识库中搜索相关文档
3. 这些文档作为上下文传递给模型
4. 模型利用真实信息回答——而不是猜测
把它想象成:
→ 闭卷考试(无 RAG):凭记忆回答,经常出错
→ 开卷考试(有 RAG):查阅资料,准确得多
为什么它强大:
→ 数据变化时无需重新训练——只需更新文档
→ 模型始终使用最新的、准确的信息
→ 大幅减少幻觉
每个严肃的 AI 产品都在使用 RAG。
客服机器人。法律工具。医疗助手。内部知识库。
## 17. 向量数据库

RAG 需要快速找到正确的文档。
但是,如何按意义——而不仅仅是关键词——搜索数百万个文档呢?
向量数据库。
工作原理如下:
1. 每个文档都被转换成一个嵌入(一组数字向量)
2. 这些向量被存储在数据库中
3. 当用户提问时,问题也变成一个向量
4. 数据库找到最接近问题向量的向量
5. 返回语义上最相似的文档
为什么这比关键词搜索更好:
→ “心脏病治疗”能找到关于“心脏护理方案”的文档
→ 即使确切的词不匹配,意义是匹配的
工具:Pinecone、Qdrant、Weaviate、pgvector
向量数据库是让 AI 系统“理解”——而不仅仅是匹配字符串的关键。
## 18. AI 代理

LLM 回复消息。
AI 代理则真正做事。
区别在于:
→ LLM:你问,它答,结束
→ 代理:你给它一个目标,它规划、采取行动、检查结果、调整、重复
代理循环:
思考 → 行动 → 观察 → 重复
例如:修复 Bug 的编程代理
→ 阅读问题报告
→ 探索代码库
→ 识别问题
→ 编写修复代码
→ 运行测试
→ 看看哪里失败了
→ 调整修复方案
→ 重复直到完成
模型是大脑。工具是手。
代理可以使用什么工具?
→ 网络搜索
→ 代码执行
→ 文件系统
→ API
→ 邮件/日历
→ 数据库
代理是将 AI 从聊天机器人变成同事的关键。
## 19. 思维链

有时 AI 得出错误答案并非因为它笨。
而是因为它太快跳到答案了。
思维链解决了这个问题。
不是直接要求最终答案:
→ “解:如果一列火车以 60 英里/小时的速度行驶 2.5 小时,能走多远?”
而是提示它一步步思考:
→ “一步步解:速度 = 60 英里/小时。时间 = 2.5 小时。距离 = 速度 × 时间 = ?”
模型会梳理推理过程:
→ 第 1 步:确定公式
→ 第 2 步:代入数字
→ 第 3 步:计算
对于数学、逻辑、多步骤问题,可靠性要高得多。
洞察:给模型思考的空间,而不仅仅是反应。
这就是为什么像“一步步思考”或“仔细推理”这样的提示词真的有用。
## 20. 扩散模型

到目前为止讲的全是文本。
扩散模型解释了 AI 如何生成图像。
这个过程很反直觉。
模型不是学习画画。
它是学习破坏图像。
训练:
→ 从一张真实图像开始
→ 一步步添加噪声,直到变成纯噪点
→ 训练模型逆转这一过程——一步步去除噪声
生成:
→ 从纯噪点开始
→ 模型一步步去除噪声
→ 在你的文本提示词引导下
→ 图像从随机噪点中浮现
这个名字来自物理学——粒子在介质中随机扩散,就像墨水在水中扩散一样。
在这里,模型学习的是逆转这种扩散。
不再仅仅是图像:
→ 视频
→ 音频
→ 3D 内容
→ 药物分子
扩散模型就是 AI g