Repository navigation
Expand file tree
/
Copy pathch22.html
More file actions
456 lines (419 loc) · 18.5 KB
/
Copy pathch22.html
File metadata and controls
456 lines (419 loc) · 18.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="AI学习笔记 - 从零开始系统学习人工智能,涵盖前置基础、核心原理、工程实践、应用工具、进阶展望">
<meta name="keywords" content="AI, 人工智能, 机器学习, 深度学习, Python, 数学基础">
<meta name="author" content="AI Learner">
<title>第二十二章:常用AI工具与平台 - AI学习笔记</title>
<!-- Google Fonts - Inter -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<!-- KaTeX - 轻量级数学公式渲染 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '\\[', right: '\\]', display: true},
{left: '\\(', right: '\\)', display: false},
{left: '$', right: '$', display: false}
],
throwOnError: false
});"></script>
<!-- Prism.js 代码高亮 - tomorrow-night 主题 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-bash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
<!-- 自定义样式表 -->
<link rel="stylesheet" href="../../css/main.css">
<link rel="stylesheet" href="../../css/dark-mode.css">
<link rel="stylesheet" href="../../css/mobile-optimizations.css">
<!-- 内联CSS样式 -->
<!-- AI-Notes共享样式 -->
<link rel="stylesheet" href="assets/ai-notes.css">
</head>
<body>
<!-- ==================== 导航栏 ==================== -->
<nav class="ai-nav">
<a href="../../index.html" class="ai-nav-brand">
<i class="fas fa-brain"></i>
AI学习笔记
</a>
<ul class="ai-nav-links" id="navLinks">
<li><a href="../../index.html"><i class="fas fa-home"></i> 首页</a></li>
<li><a href="ch15.html"><i class="fas fa-robot"></i> Agent</a></li>
<li><a href="ch16.html"><i class="fas fa-tools"></i> 工具</a></li>
<li><a href="ch17.html"><i class="fas fa-book-open"></i> 知识库</a></li>
<li><a href="ch18.html"><i class="fas fa-layer-group"></i> 记忆</a></li>
<li><a href="ch19.html"><i class="fas fa-comment-dots"></i> 提示</a></li>
<li><a href="ch20.html"><i class="fas fa-database"></i> 数据</a></li>
<li><a href="ch21.html"><i class="fas fa-exclamation-circle"></i> 局限</a></li>
<li><a href="ch22.html"><i class="fas fa-toolbox"></i> 平台</a></li>
<li><a href="ch23.html"><i class="fas fa-history"></i> 简史</a></li>
<li><a href="ch24.html"><i class="fas fa-rocket"></i> 实战</a></li>
</ul>
<button class="ai-nav-toggle" id="navToggle" aria-label="切换导航">
<i class="fas fa-bars"></i>
</button>
</nav>
<!-- ==================== Hero Section ==================== -->
<section class="ai-hero">
<h1><i class="fas fa-brain"></i> AI 学习笔记</h1>
<p>第二十二章:常用AI工具与平台</p>
<div class="ai-hero-badges">
<span class="ai-hero-badge"><i class="fas fa-book"></i> 系统学习</span>
<span class="ai-hero-badge"><i class="fas fa-code"></i> 实践导向</span>
</div>
</section>
<!-- ==================== 主内容区域 ==================== -->
<div class="content-wrapper">
<!-- ========== 主内容 ========== -->
<main class="main-content">
<nav class="ai-chapter-nav">
<div class="breadcrumb">
<a href="../../index.html"><i class="fas fa-home"></i> 首页</a>
<span class="separator">/</span>
<span class="current">第二十二章:常用AI工具与平台</span>
</div>
<div class="chapter-nav-links">
<a href="ch21.html" class="prev-chapter"><i class="fas fa-arrow-left"></i> 上一章</a>
<a href="ch23.html" class="next-chapter">下一章 <i class="fas fa-arrow-right"></i></a>
</div>
</nav>
<!-- 第二十二章:常用AI工具与平台 -->
<!-- ============================================================ -->
<h2 class="ai-section-title"><i class="fas fa-toolbox"></i> 第二十二章:常用AI工具与平台</h2>
<div class="ai-box ai-box--objectives">
<h3><i class="fas fa-bullseye"></i> 学习目标</h3>
<ul>
<li>了解主流AI助手的特点和适用场景</li>
<li>了解图像生成工具的能力和选择</li>
<li>掌握Hugging Face平台的使用方法</li>
<li>了解开源vs闭源模型的选择考量</li>
<li>了解AI编程工具的对比</li>
</ul>
</div>
<div class="ai-box ai-box--prereq">
<h3><i class="fas fa-book"></i> 前置要求</h3>
<p>无特殊前置要求,本章为独立章节,适合所有读者。</p>
</div>
<figure class="ai-figure">
<img src="https://trae-api-cn.mchost.guru/api/ide/v1/text_to_image?prompt=AI%20development%20tools%20and%20platforms%20overview%20landscape%2C%20popular%20AI%20assistants%20and%20IDEs%20comparison%2C%20clean%20educational%20infographic%20style%2C%20flat%20design%2C%20white%20background&image_size=landscape_4_3" alt="常用AI工具与平台概览图" loading="lazy">
<figcaption><strong>图22-1</strong> 常用AI工具与平台概览:主流AI助手、开发IDE、模型平台和应用框架的全景对比</figcaption>
</figure>
<div class="concept-section">
<h2><i class="fas fa-comments"></i> 主流AI助手</h2>
<table class="comparison-table">
<tr>
<th>AI助手</th>
<th>开发者</th>
<th>核心特点</th>
<th>适用场景</th>
</tr>
<tr>
<td><strong>ChatGPT</strong></td>
<td>OpenAI</td>
<td>功能全面、插件生态丰富、GPT-4o多模态</td>
<td>通用对话、写作、编程、分析</td>
</tr>
<tr>
<td><strong>Claude</strong></td>
<td>Anthropic</td>
<td>长上下文(200K)、安全对齐好、分析能力强</td>
<td>长文档分析、代码审查、学术研究</td>
</tr>
<tr>
<td><strong>文心一言</strong></td>
<td>百度</td>
<td>中文优化好、集成百度搜索</td>
<td>中文场景、知识问答</td>
</tr>
<tr>
<td><strong>通义千问</strong></td>
<td>阿里巴巴</td>
<td>开源版本可用、多模态支持</td>
<td>中文场景、企业应用</td>
</tr>
</table>
<h2><i class="fas fa-palette"></i> 图像生成工具</h2>
<table class="comparison-table">
<tr>
<th>工具</th>
<th>开发者</th>
<th>核心特点</th>
<th>适用场景</th>
</tr>
<tr>
<td><strong>Midjourney</strong></td>
<td>Midjourney</td>
<td>艺术风格强、画面精美</td>
<td>艺术创作、概念设计</td>
</tr>
<tr>
<td><strong>DALL-E 3</strong></td>
<td>OpenAI</td>
<td>与ChatGPT集成、文字理解准确</td>
<td>精确控制生成内容</td>
</tr>
<tr>
<td><strong>Stable Diffusion</strong></td>
<td>Stability AI</td>
<td>开源、可本地部署、高度可定制</td>
<td>批量生成、定制模型</td>
</tr>
</table>
</div>
<div class="concept-section">
<h2><i class="fas fa-rocket"></i> Hugging Face</h2>
<p><span class="keyword-highlight">Hugging Face</span>是AI领域最大的开源社区和模型托管平台,被称为"AI领域的GitHub"。</p>
<h3>Hugging Face提供的内容</h3>
<ul>
<li><strong>模型(Models)</strong>:数十万个预训练模型,涵盖NLP、CV、音频等多个领域</li>
<li><strong>数据集(Datasets)</strong>:数千个公开数据集,方便下载和使用</li>
<li><strong>Spaces</strong>:在线演示空间,可以快速部署和展示AI应用</li>
<li><strong>Transformers库</strong>:最流行的深度学习库之一,提供统一的API加载各种模型</li>
</ul>
<h3>使用Hugging Face的基本步骤</h3>
<div class="flow-diagram">
<div class="flow-step">
<div class="step-number">1</div>
<div class="step-content">
<h4>注册账号</h4>
<p>在huggingface.co注册免费账号</p>
</div>
</div>
<div class="flow-arrow"><i class="fas fa-arrow-down"></i></div>
<div class="flow-step">
<div class="step-number">2</div>
<div class="step-content">
<h4>浏览模型</h4>
<p>搜索和筛选适合的预训练模型</p>
</div>
</div>
<div class="flow-arrow"><i class="fas fa-arrow-down"></i></div>
<div class="flow-step">
<div class="step-number">3</div>
<div class="step-content">
<h4>安装依赖</h4>
<p>安装transformers和torch库</p>
</div>
</div>
<div class="flow-arrow"><i class="fas fa-arrow-down"></i></div>
<div class="flow-step">
<div class="step-number">4</div>
<div class="step-content">
<h4>加载使用</h4>
<p>用几行代码加载模型并进行推理</p>
</div>
</div>
</div>
<h3>Python代码示例</h3>
<pre><code class="language-python">from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
import torch
# 方法1:使用pipeline快速使用(最简单)
classifier = pipeline("sentiment-analysis", model="uer/roberta-base-finetuned-jd-binary-chinese")
result = classifier("这个产品质量非常好,推荐购买!")
print(result) # [{'label': 'positive', 'score': 0.98}]
# 方法2:加载具体模型(更灵活)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct")
model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct",
torch_dtype=torch.float16,
device_map="auto"
)
messages = [
{"role": "system", "content": "你是一个有帮助的AI助手。"},
{"role": "user", "content": "用一句话介绍什么是机器学习。"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=100)
response = outputs[0][inputs.input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))</code></pre>
</div>
<div class="concept-section">
<h2><i class="fas fa-code-branch"></i> 开源 vs 闭源模型</h2>
<table class="comparison-table">
<tr>
<th>维度</th>
<th>开源模型</th>
<th>闭源模型</th>
</tr>
<tr>
<td><strong>代表</strong></td>
<td>Llama、Qwen、GLM、Mistral</td>
<td>GPT-4、Claude、Gemini</td>
</tr>
<tr>
<td><strong>可访问性</strong></td>
<td>可下载权重、查看源码、自由修改</td>
<td>仅通过API调用,无法查看内部</td>
</tr>
<tr>
<td><strong>成本</strong></td>
<td>需自行部署和维护硬件</td>
<td>按使用量付费,无需管理基础设施</td>
</tr>
<tr>
<td><strong>数据隐私</strong></td>
<td>数据不出本地,完全可控</td>
<td>数据需发送到第三方服务器</td>
</tr>
<tr>
<td><strong>定制化</strong></td>
<td>可自由微调、修改、蒸馏</td>
<td>功能由服务商决定</td>
</tr>
<tr>
<td><strong>性能上限</strong></td>
<td>略低于顶级闭源模型</td>
<td>通常性能最强</td>
</tr>
</table>
<div class="concept-box">
<h4><i class="fas fa-lightbulb"></i> 如何选择?</h4>
<p><strong>选闭源</strong>:追求最强性能、不想管理基础设施、快速验证想法。<br/>
<strong>选开源</strong>:数据隐私要求高、需要深度定制、长期成本控制、学习研究目的。</p>
</div>
<h3>主流开源模型</h3>
<ul>
<li><strong>Llama 3</strong>(Meta):性能优异,社区活跃</li>
<li><strong>Qwen2.5</strong>(阿里巴巴):中文能力强,多模态支持</li>
<li><strong>GLM-4</strong>(智谱AI):中文优化,长上下文</li>
<li><strong>Mistral</strong>(Mistral AI):欧洲代表,高效架构</li>
<li><strong>DeepSeek</strong>(深度求索):推理能力强,性价比高</li>
</ul>
</div>
<div class="concept-section">
<h2><i class="fas fa-laptop-code"></i> AI编程工具对比</h2>
<table class="comparison-table">
<tr>
<th>工具</th>
<th>开发者</th>
<th>核心特点</th>
<th>适用场景</th>
</tr>
<tr>
<td><strong>Claude Code</strong></td>
<td>Anthropic</td>
<td>终端AI编程助手、理解整个代码库、自主执行复杂任务</td>
<td>全栈开发、代码重构、Bug修复</td>
</tr>
<tr>
<td><strong>GitHub Copilot</strong></td>
<td>GitHub/Microsoft</td>
<td>IDE集成、实时代码补全、多模型支持</td>
<td>日常编码、代码补全、快速开发</td>
</tr>
<tr>
<td><strong>Cursor</strong></td>
<td>Cursor Inc.</td>
<td>AI原生IDE、代码库理解、多文件编辑</td>
<td>项目级开发、代码重构</td>
</tr>
<tr>
<td><strong>Windsurf</strong></td>
<td>Codeium</td>
<td>AI IDE、Cascade多步推理、免费额度</td>
<td>日常开发、学习编程</td>
</tr>
</table>
</div>
<div class="ai-box ai-box--summary">
<h3><i class="fas fa-clipboard-list"></i> 本章小结</h3>
<ol>
<li>主流AI助手各有特色:ChatGPT功能全面,Claude擅长长文档分析,国产模型在中文场景表现优秀。</li>
<li>Hugging Face是AI领域的核心平台,提供模型、数据集、Spaces和Transformers库,是AI开发者必备工具。</li>
<li>开源模型(Llama、Qwen等)提供数据隐私和定制化优势,闭源模型(GPT-4、Claude等)提供最强性能和便捷性。</li>
<li>AI编程工具(Claude Code、Copilot、Cursor、Windsurf)正在改变开发方式,选择需考虑集成方式、代码库理解能力和使用成本。</li>
</ol>
</div>
<div class="ai-box ai-box--exercise">
<h3><i class="fas fa-pencil-alt"></i> 练习题</h3>
<ol>
<li>
<p><strong>Hugging Face平台主要提供哪些内容?</strong></p>
<p>A. 仅提供模型下载<br/>B. 模型、数据集、Spaces和Transformers库<br/>C. 仅提供云计算服务<br/>D. 仅提供数据标注工具</p>
<p><strong>答案:B</strong>。Hugging Face提供模型(Models)、数据集(Datasets)、在线演示空间(Spaces)和Transformers库等丰富的AI资源和工具。</p>
</li>
<li>
<p><strong>以下哪种场景更适合选择开源模型?</strong></p>
<p>A. 追求最强性能,不想管理基础设施<br/>B. 数据隐私要求高,需要本地部署<br/>C. 快速验证想法,不想投入硬件<br/>D. 需要最新的多模态能力</p>
<p><strong>答案:B</strong>。开源模型可以本地部署,数据不出本地,完全可控,最适合数据隐私要求高的场景。</p>
</li>
<li>
<p><strong>以下哪个AI编程工具是终端原生的AI编程助手?</strong></p>
<p>A. GitHub Copilot<br/>B. Cursor<br/>C. Claude Code<br/>D. Windsurf</p>
<p><strong>答案:C</strong>。Claude Code是Anthropic推出的终端原生AI编程助手,直接在命令行中运行,能理解整个代码库并自主执行复杂任务。</p>
</li>
</ol>
</div>
<!-- ============================================================ -->
</main>
</div>
<!-- 页脚 -->
<!-- ============================================================ -->
<footer class="footer">
<div class="footer-content">
<div class="footer-section">
<h3><i class="fas fa-graduation-cap"></i> AI学习笔记</h3>
<p>从零开始系统学习人工智能</p>
<p>涵盖前置基础、核心原理、工程实践、应用工具、进阶展望</p>
</div>
<div class="footer-section">
<h3><i class="fas fa-bookmark"></i> 内容导航</h3>
<p>第1-11章:基础与核心(见 ai-notes-core.html)</p>
<p>第12-23章:工程实践与进阶(本文件)</p>
<p>附录A:GPU与算力指南</p>
<p>附录B:术语表</p>
</div>
<div class="footer-section">
<h3><i class="fas fa-info-circle"></i> 说明</h3>
<p>本笔记仅供学习参考,内容如有错误欢迎指正。</p>
<p>AI技术发展迅速,部分信息可能随时间变化。</p>
</div>
</div>
<div class="footer-bottom">
<p>AI学习笔记 © 2024 | 持续更新中</p>
</div>
</footer>
</div><!-- /ai-notes-container -->
<!-- Scripts -->
<script src="../../js/mobile-menu.js"></script>
<script src="../../js/dark-mode.js"></script>
<script>
// 目录滚动高亮
(function() {
const tocLinks = document.querySelectorAll('.toc-sidebar a');
const sections = [];
tocLinks.forEach(link => {
const id = link.getAttribute('href');
if (id && id.startsWith('#')) {
const el = document.querySelector(id);
if (el) sections.push({ link, el });
}
});
function updateActive() {
const scrollY = window.scrollY + 100;
let current = sections[0];
for (const s of sections) {
if (s.el.offsetTop <= scrollY) current = s;
}
tocLinks.forEach(l => l.classList.remove('active'));
if (current) current.link.classList.add('active');
}
window.addEventListener('scroll', updateActive);
updateActive();
})();
</script>
<script src="assets/ai-notes.js"></script>
</body>
</html>