Skip to content

Commit c418bba

Browse files
authored
[Docs] Change tables to list items (#10656)
1 parent eb43056 commit c418bba

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

llm/docs/finetune_tutorial.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
## 1. 什么是精调 (Fine-tuning)
88
经过预训练,我们拥有了经过预训练之后的基础模型,但是这个模型如果直接应用在某一个特定领域,效果可能并不太好。这是由于我们的预训练语料没有针对特定的任务场景进行特化。但是大模型经过预训练已经拥有了很强的通用能力,只需要少量特定数据,就可以大幅提升大模型在特定领域的能力。
99

10-
我们用一个表格来简单对比下预训练与精调:
11-
| 对比项 | 预训练 | 精调 |
12-
| ---- | -------- | --------- |
13-
| 数据量 | 海量通用文本 | 少量特定任务数据 |
14-
| 目标 | 学习通用语言知识 | 优化具体任务表现 |
15-
| 训练时间 | 很长 | 较短 |
10+
我们简单对比下预训练与精调:
11+
* 数据量:(预训练)海量通用文本/(精调)少量特定任务数据
12+
* 训练目标:(预训练)学习通用语言知识/(精调)优化具体任务表现
13+
* 训练时间:(预训练)很长/(精调)较短
1614

1715
## 2. 精调数据
1816
与预训练的无监督数据不同,精调使用的数据是有监督数据,一般是一个指令(向大模型说的话)和一个输出(大模型应该的回应)。常用的数据格式是[Alpaca](https://crfm.stanford.edu/2023/03/13/alpaca.html),我们用一个简单的例子来展示一下其基本组成:
@@ -108,11 +106,7 @@ python run_finetune.py ./config/qwen/pt_argument_0p5b.json
108106
<img src=https://github.com/PaddlePaddle/PaddleNLP/assets/37530985/63d56558-247a-4a8d-a6ca-121c820f7534 width=30% height=30% />
109107
</div>
110108

111-
LoRA(Low-rank Adaptation)方法向模型插入少量可训练的低秩矩阵,在不改变原模型参数的前提下,完成微调任务。参考图里面的示例,一个很大的灰色参数矩阵可以近似分解为两个较小的矩阵 A 与 B 相乘:
112-
113-
$$\Delta W \approx A \cdot B$$
114-
115-
这样一个大矩阵就被分解为了两个小矩阵,需要微调的参数量大大减少。在训练完成后,在推理的过程中将原本的参数矩阵与微调的参数矩阵相加,既不影响原本的预训练参数,也可以实现微调效果,这样的优点也让 LoRA 成为了大模型微调的热门方法。
109+
LoRA(Low-rank Adaptation)方法向模型插入少量可训练的低秩矩阵,在不改变原模型参数的前提下,完成微调任务。参考图里面的示例,一个很大的灰色参数矩阵可以近似分解为两个较小的矩阵 A 与 B 相乘。这样一个大矩阵就被分解为了两个小矩阵,需要微调的参数量大大减少。在训练完成后,在推理的过程中将原本的参数矩阵与微调的参数矩阵相加,既不影响原本的预训练参数,也可以实现微调效果,这样的优点也让 LoRA 成为了大模型微调的热门方法。
116110

117111

118112
```python

llm/docs/pretrain_tutorial.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ python -u ~/PaddleNLP/llm/run_pretrain.py ~/PaddleNLP/llm/config/qwen/pretrain_a
8080

8181
看到下面的提示说明已经开始进行训练了:
8282
```
83-
[2025-05-18 10:13:15,353] [ INFO] - loss: 12.0635252, learning_rate: 2e-06, global_step: 1, current_memory_allocated: 7.549170255661011, current_memory_reserved: 7.753237724304199, max_memory_allocated: 7.549170255661011, max_memory_reserved: 7.753237724304199, interval_runtime: 1.1518, interval_samples_per_second: 0.8682, interval_tokens_per_second_per_device: 889.0448, interval_hardware_tflops_per_device: 2.77, interval_steps_per_second: 0.8682, progress_or_epoch: 0.0
84-
[2025-05-18 10:13:15,607] [ INFO] - loss: 12.05887604, learning_rate: 3e-06, global_step: 2, current_memory_allocated: 7.549170255661011, current_memory_reserved: 12.4834623336792, max_memory_allocated: 12.307440280914307, max_memory_reserved: 12.4834623336792, interval_runtime: 0.2556, interval_samples_per_second: 3.913, interval_tokens_per_second_per_device: 4006.9441, interval_hardware_tflops_per_device: 12.49, interval_steps_per_second: 3.913, progress_or_epoch: 0.0
83+
[ INFO] - loss: 12.0635252, learning_rate: 2e-06, global_step: 1, current_memory_allocated: 7.549170255661011, current_memory_reserved: 7.753237724304199, max_memory_allocated: 7.549170255661011, max_memory_reserved: 7.753237724304199, interval_runtime: 1.1518, interval_samples_per_second: 0.8682, interval_tokens_per_second_per_device: 889.0448, interval_hardware_tflops_per_device: 2.77, interval_steps_per_second: 0.8682, progress_or_epoch: 0.0
84+
[ INFO] - loss: 12.05887604, learning_rate: 3e-06, global_step: 2, current_memory_allocated: 7.549170255661011, current_memory_reserved: 12.4834623336792, max_memory_allocated: 12.307440280914307, max_memory_reserved: 12.4834623336792, interval_runtime: 0.2556, interval_samples_per_second: 3.913, interval_tokens_per_second_per_device: 4006.9441, interval_hardware_tflops_per_device: 12.49, interval_steps_per_second: 3.913, progress_or_epoch: 0.0
8585
```
8686

8787
### FAQ1:显存不足
@@ -131,29 +131,29 @@ python -u -m paddle.distributed.launch --devices "0,1,2,3,4,5,6,7" --master=192
131131
### 3.3 训练结果
132132
当训练结束时,可以看到下面的输出:
133133
```
134-
[2025-05-18 10:49:13,774] [ INFO] - Saving model checkpoint to ./checkpoints/pretrain_ckpts
135-
[2025-05-18 10:49:13,775] [ INFO] - tokenizer config file saved in ./checkpoints/pretrain_ckpts/tokenizer_config.json
136-
[2025-05-18 10:49:13,776] [ INFO] - Special tokens file saved in ./checkpoints/pretrain_ckpts/special_tokens_map.json
137-
[2025-05-18 10:49:13,776] [ INFO] - added tokens file saved in ./checkpoints/pretrain_ckpts/added_tokens.json
138-
[2025-05-18 10:49:13,803] [ WARNING] - Asynchronous saving is not supported for single card environment currently.
139-
[2025-05-18 10:49:15,691] [ INFO] - Configuration saved in ./checkpoints/pretrain_ckpts/config.json
140-
[2025-05-18 10:49:15,694] [ INFO] - Configuration saved in ./checkpoints/pretrain_ckpts/generation_config.json
141-
[2025-05-18 10:49:15,695] [ INFO] - ***** train metrics *****
142-
[2025-05-18 10:49:15,695] [ INFO] - progress_or_epoch = 0.0868
143-
[2025-05-18 10:49:15,695] [ INFO] - train_loss = 5.4334
144-
[2025-05-18 10:49:15,695] [ INFO] - train_runtime = 0:35:59.57
145-
[2025-05-18 10:49:15,696] [ INFO] - train_samples_per_second = 4.6305
146-
[2025-05-18 10:49:15,696] [ INFO] - train_steps_per_second = 4.6305
147-
[2025-05-18 10:49:15,697] [ INFO] - ***** Running Prediction *****
148-
[2025-05-18 10:49:15,697] [ INFO] - Num examples = 258
149-
[2025-05-18 10:49:15,697] [ INFO] - Total prediction steps = 129
150-
[2025-05-18 10:49:15,697] [ INFO] - Pre device batch size = 2
151-
[2025-05-18 10:49:15,697] [ INFO] - Total Batch size = 2
152-
[2025-05-18 10:49:28,420] [ INFO] - ***** test metrics *****
153-
[2025-05-18 10:49:28,420] [ INFO] - test_loss = 4.8691
154-
[2025-05-18 10:49:28,420] [ INFO] - test_runtime = 0:00:12.72
155-
[2025-05-18 10:49:28,420] [ INFO] - test_samples_per_second = 20.2781
156-
[2025-05-18 10:49:28,420] [ INFO] - test_steps_per_second = 10.1391
134+
[ INFO] - Saving model checkpoint to ./checkpoints/pretrain_ckpts
135+
[ INFO] - tokenizer config file saved in ./checkpoints/pretrain_ckpts/tokenizer_config.json
136+
[ INFO] - Special tokens file saved in ./checkpoints/pretrain_ckpts/special_tokens_map.json
137+
[ INFO] - added tokens file saved in ./checkpoints/pretrain_ckpts/added_tokens.json
138+
[ WARNING] - Asynchronous saving is not supported for single card environment currently.
139+
[ INFO] - Configuration saved in ./checkpoints/pretrain_ckpts/config.json
140+
[ INFO] - Configuration saved in ./checkpoints/pretrain_ckpts/generation_config.json
141+
[ INFO] - ***** train metrics *****
142+
[ INFO] - progress_or_epoch = 0.0868
143+
[ INFO] - train_loss = 5.4334
144+
[ INFO] - train_runtime = 0:35:59.57
145+
[ INFO] - train_samples_per_second = 4.6305
146+
[ INFO] - train_steps_per_second = 4.6305
147+
[ INFO] - ***** Running Prediction *****
148+
[ INFO] - Num examples = 258
149+
[ INFO] - Total prediction steps = 129
150+
[ INFO] - Pre device batch size = 2
151+
[ INFO] - Total Batch size = 2
152+
[ INFO] - ***** test metrics *****
153+
[ INFO] - test_loss = 4.8691
154+
[ INFO] - test_runtime = 0:00:12.72
155+
[ INFO] - test_samples_per_second = 20.2781
156+
[ INFO] - test_steps_per_second = 10.1391
157157
Effective Tokens per second: 4741.68
158158
ips: 4741.68 tokens/s
159159
```

0 commit comments

Comments
 (0)