docs:add docsify deploy
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
Transformers 是由 Hugging Face 开发的 NLP 框架,通过模块化设计实现了对 BERT、GPT、LLaMA、T5、ViT 等上百种主流模型架构的统一支持。通过使用 Transformers,开发者无需重复实现基础网络结构,通过 AutoModel 类即可一键加载任意预训练,图6.1 为 Hugging Face Transformers 课程首页:
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/1-1.png" alt="alt text" width="90%">
|
||||
<img src="../images/6-images/1-1.png" alt="alt text" width="90%">
|
||||
<p>图6.1 Hugging Face Transformers</p>
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,7 @@ Transformers 是由 Hugging Face 开发的 NLP 框架,通过模块化设计实
|
||||
对 LLM 时代的 NLP 研究者更为重要的是,HuggingFace 基于 Transformers 框架搭建了其庞大的 AI 社区,开放了数亿个预训练模型参数、25万+不同类型数据集,通过 Transformers、Dataset、Evaluate 等多个框架实现对预训练模型、数据集及评估函数的集成,从而帮助开发者可以便捷地使用任一预训练模型,在开源模型及数据集的基础上便捷地实现个人模型的开发与应用。
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/1-2.png" alt="alt text" width="90%">
|
||||
<img src="../images/6-images/1-2.png" alt="alt text" width="90%">
|
||||
<p>图6.2 Hugging Face Transformers 模型社区</p>
|
||||
</div>
|
||||
|
||||
@@ -35,14 +35,14 @@ Transformers 是由 Hugging Face 开发的 NLP 框架,通过模块化设计实
|
||||
我们可以使用 transformers 的 AutoModel 类来直接初始化已经实现好的模型。对于任意预训练模型,其参数中都包含有模型的配置信息。如果是想要从头训练一个 LLM,可以使用一个已有的模型架构来直接初始化。这里,我们以 [Qwen-2.5-1.5B](https://huggingface.co/Qwen/Qwen2.5-1.5B/tree/main)的模型架构为例:
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/1-3.png" alt="alt text" width="90%">
|
||||
<img src="../images/6-images/1-3.png" alt="alt text" width="90%">
|
||||
<p>图6.3 Qwen-2.5-1.5B</p>
|
||||
</div>
|
||||
|
||||
该界面即为 HuggingFace 社区中的 Qwen-2.5-1.5B 模型参数,其中的 `config.json` 文件即是模型的配置信息,包括了模型的架构、隐藏层大小、模型层数等,如图6.4所示:
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/1-4.png" alt="alt text" width="90%">
|
||||
<img src="../images/6-images/1-4.png" alt="alt text" width="90%">
|
||||
<p>图6.4 Qwen-2.5-1.5B config.json 文件</p>
|
||||
</div>
|
||||
|
||||
@@ -59,7 +59,7 @@ os.system('huggingface-cli download --resume-download Qwen/Qwen2.5-1.5B --local-
|
||||
如图6.5,此处的 “Qwen/Qwen2.5-1.5B”即为要下载模型的标识符,对于其他模型,可以直接复制 HuggingFace 上的模型名即可:
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/1-5.png" alt="alt text" width="90%">
|
||||
<img src="../images/6-images/1-5.png" alt="alt text" width="90%">
|
||||
<p>图6.5 模型下载标识</p>
|
||||
</div>
|
||||
|
||||
@@ -87,7 +87,7 @@ model = AutoModelForCausalLM.from_config(config,trust_remote_code=True)
|
||||
由于 LLM 一般都是 CausalLM 架构,此处使用了 AutoModelForCausalLM 类进行加载。如果是用于分类任务训练,可使用 AutoModelForSequenceClassification 类来加载。查看该 model,图6.6可以看到其架构和定义的配置文件相同:
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/1-6.png" alt="alt text" width="70%">
|
||||
<img src="../images/6-images/1-6.png" alt="alt text" width="70%">
|
||||
<p>图6.6 模型结构输出结果</p>
|
||||
</div>
|
||||
|
||||
@@ -130,7 +130,7 @@ ds["train"][0]
|
||||
```
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/1-7.png" alt="alt text" width="100%">
|
||||
<img src="../images/6-images/1-7.png" alt="alt text" width="100%">
|
||||
<p>图6.7 数据集展示</p>
|
||||
</div>
|
||||
|
||||
@@ -788,7 +788,7 @@ trainer.save_model()
|
||||
具体而言,其在预训练模型每层中插入用于下游任务的参数,即 Adapter 模块,在微调时冻结模型主体,仅训练特定于任务的参数,如图6.8所示。
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/3-1.png" alt="alt text" width="90%">
|
||||
<img src="../images/6-images/3-1.png" alt="alt text" width="90%">
|
||||
<p>图6.8 Adapt Tuning</p>
|
||||
</div>
|
||||
|
||||
@@ -840,7 +840,7 @@ $$h = W_0 x + \Delta W x = W_0 x + B A x$$
|
||||
训练思路如图6.9所示:
|
||||
|
||||
<div align='center'>
|
||||
<img src="./images/3-2.jpg" alt="alt text" width="90%">
|
||||
<img src="../images/6-images/3-2.jpg" alt="alt text" width="90%">
|
||||
<p>图6.9 LoRA</p>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user