1
1
# LLaMA
2
2
3
- 本文档展示了如何在 PaddleNLP中构建和运行 [ LLaMA] ( https://llama.meta.com/ ) 系列大模型。
3
+ 本文档展示了如何在 PaddleNLP 中构建和运行 [ LLaMA] ( https://llama.meta.com/ ) 系列大模型。
4
4
5
5
## 模型介绍
6
6
7
7
* LLaMA 系列大模型是由 Meta AI 发布的一个开放且高效的大型基础语言模型。
8
8
9
- * [ Llama 2] ( https://llama.meta.com/llama2/ ) :2023年7月,Meta发布了Llama 2系列,有7B、13B、34B和70B四个版本 。该版本实现了开源商用,降低了初创公司创建类似ChatGPT聊天机器人的成本 。
9
+ * [ Llama 2] ( https://llama.meta.com/llama2/ ) :2023年7月,Meta 发布了 Llama 2系列,有7B、13B、34B 和70B 四个版本 。该版本实现了开源商用,降低了初创公司创建类似 ChatGPT 聊天机器人的成本 。
10
10
11
- * [ Llama 3] ( https://llama.meta.com/ ) :2024年4月19日,Meta推出了Llama 3系列,包括8B和70B两个版本,400B的Llama -3还在训练中。该版本在多个基准测试中取得了全面进步,性能优异。
11
+ * [ Llama 3] ( https://llama.meta.com/ ) :2024年4月19日,Meta 推出了 Llama 3系列,包括8B 和70B 两个版本,400B 的 Llama -3还在训练中。该版本在多个基准测试中取得了全面进步,性能优异。
12
12
13
- * [ Llama 3.1] ( https://llama.meta.com/ ) :2024年7月23日,Meta发布了Llama 3.1 8B、70B、405B模型 ,进一步提升了模型的性能和效率。
13
+ * [ Llama 3.1] ( https://llama.meta.com/ ) :2024年7月23日,Meta 发布了 Llama 3.1 8B、70B、405B 模型 ,进一步提升了模型的性能和效率。
14
14
15
- ## 模型支持
15
+ ## 已验证的模型
16
16
17
- | Model |
18
- | :----------------------------: |
19
- | meta-llama/Llama-2-7b(-chat) |
20
- | meta-llama/Llama-2-13b(-chat) |
21
- | meta-llama/Llama-2-70b(-chat) |
22
- | meta-llama/Meta-Llama-3-8B(-Instruct) |
23
- | meta-llama/Meta-Llama-3-70B(-Instruct) |
24
- | meta-llama/Meta-Llama-3.1-8B(-Instruct) |
25
- | meta-llama/Meta-Llama-3.1-70B(-Instruct) |
26
- | meta-llama/Meta-Llama-3.1-405B(-Instruct) |
17
+ | Model|
18
+ | :-|
19
+ | meta-llama/Llama-2-7b-chat|
20
+ | meta-llama/Llama-2-13b-chat|
21
+ | meta-llama/Llama-2-70b-chat|
22
+ | meta-llama/Meta-Llama-3-8B-Instruct|
23
+ | meta-llama/Meta-Llama-3-70B-Instruct|
24
+ | meta-llama/Meta-Llama-3.1-8B-Instruct|
25
+ | meta-llama/Meta-Llama-3.1-70B-Instruct|
26
+ | meta-llama/Meta-Llama-3.1-405B-Instruct|
27
+
28
+ ## 已验证的预量化模型
29
+
30
+ | Model|
31
+ | :-|
32
+ | meta-llama/Meta-Llama-3-8B-Instruct-A8W8C8|
33
+ | meta-llama/Meta-Llama-3-8B-Instruct-A8W8-FP8|
34
+ | meta-llama/Meta-Llama-3.1-8B-Instruct-A8W8C8|
35
+ | meta-llama/Meta-Llama-3.1-8B-Instruct-A8W8-FP8|
27
36
28
37
29
38
## 模型推理
30
39
31
- 以meta -llama/Meta-Llama-3-8B-Instruct单卡和meta -llama/Meta-Llama-3.1-405B-Instruct多卡为例 。
40
+ 以 meta -llama/Meta-Llama-3-8B-Instruct 单卡和 meta -llama/Meta-Llama-3.1-405B-Instruct 多卡为例 。
32
41
33
42
BF16推理
34
43
@@ -57,7 +66,7 @@ python predict/export_model.py --model_name_or_path meta-llama/Meta-Llama-3-8B-I
57
66
python predict/predictor.py --model_name_or_path /path/to/exported_model --dtype bfloat16 --mode static --inference_model 1 --block_attn 1 --quant_type weight_only_int8
58
67
```
59
68
60
- 下面量化推理所需要的模型需要根据[ 大模型量化教程] ( ../quantization.md ) 产出。
69
+ 下面量化推理所需要的模型需要根据[ 大模型量化教程] ( ../quantization.md ) 产出,如 checkpoints/llama_ptq_ckpts,或者使用所提供的预先量化好的模型,如 meta-llama/Meta-Llama-3-8B-Instruct-A8W8C8 。
61
70
62
71
INT8-A8W8推理
63
72
@@ -76,10 +85,10 @@ INT8-A8W8C8推理
76
85
77
86
``` shell
78
87
# 动态图推理
79
- python predict/predictor.py --model_name_or_path checkpoints/llama_ptq_ckpts --dtype bfloat16 --mode dynamic --inference_model 1 --block_attn 1 --quant_type a8w8 --cachekv_int8_type static
88
+ python predict/predictor.py --model_name_or_path meta-llama/Meta-Llama-3-8B-Instruct-A8W8C8 --dtype bfloat16 --mode dynamic --inference_model 1 --block_attn 1 --quant_type a8w8 --cachekv_int8_type static
80
89
81
90
# 动转静导出模型
82
- python predict/export_model.py --model_name_or_path checkpoints/llama_ptq_ckpts --output_path /path/to/exported_model --dtype bfloat16 --inference_model 1 --block_attn 1 --quant_type a8w8 --cachekv_int8_type static
91
+ python predict/export_model.py --model_name_or_path meta-llama/Meta-Llama-3-8B-Instruct-A8W8C8 --output_path /path/to/exported_model --dtype bfloat16 --inference_model 1 --block_attn 1 --quant_type a8w8 --cachekv_int8_type static
83
92
84
93
# 静态图推理
85
94
python predict/predictor.py --model_name_or_path /path/to/exported_model --dtype bfloat16 --mode static --inference_model 1 --block_attn 1 --quant_type a8w8 --cachekv_int8_type static
@@ -88,10 +97,10 @@ python predict/predictor.py --model_name_or_path /path/to/exported_model --dtype
88
97
FP8-A8W8推理
89
98
``` shell
90
99
# 动态图推理
91
- python predict/predictor.py --model_name_or_path checkpoints/llama_ptq_ckpts --dtype bfloat16 --mode dynamic --inference_model 1 --block_attn 1 --quant_type a8w8_fp8
100
+ python predict/predictor.py --model_name_or_path meta-llama/Meta-Llama-3-8B-Instruct-A8W8-FP8 --dtype bfloat16 --mode dynamic --inference_model 1 --block_attn 1 --quant_type a8w8_fp8
92
101
93
102
# 动转静导出模型
94
- python predict/export_model.py --model_name_or_path checkpoints/llama_ptq_ckpts --output_path /path/to/exported_model --dtype bfloat16 --inference_model 1 --block_attn 1 --quant_type a8w8_fp8
103
+ python predict/export_model.py --model_name_or_path meta-llama/Meta-Llama-3-8B-Instruct-A8W8-FP8 --output_path /path/to/exported_model --dtype bfloat16 --inference_model 1 --block_attn 1 --quant_type a8w8_fp8
95
104
96
105
# 静态图推理
97
106
python predict/predictor.py --model_name_or_path /path/to/exported_model --dtype bfloat16 --mode static --inference_model 1 --block_attn 1 --quant_type a8w8_fp8
@@ -108,13 +117,12 @@ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-405B-Instru
108
117
generation_config = GenerationConfig.from_pretrained(" meta-llama/Meta-Llama-3.1-405B-Instruct" )
109
118
```
110
119
111
- 这里通过--use_fake_parameter使用fake parameters,如需要推理正确的量化模型,请自行参考[ 大模型量化教程] ( ../quantization.md ) 进行量化。
120
+ 这里通过--use_fake_parameter 使用 fake parameters,如需要推理正确的量化模型,请自行参考[ 大模型量化教程] ( ../quantization.md ) 进行量化。
112
121
113
122
``` shell
114
123
# 导出模型 (可在predict/export_model.py中设置paddle.set_device("cpu"),通过内存导出模型)
115
124
python -m paddle.distributed.launch --gpus " 0,1,2,3,4,5,6,7" predict/export_model.py --model_name_or_path meta-llama/Meta-Llama-3.1-405B-Instruct --output_path /path/to/a8w8c8_tp8 --inference_model 1 --block_attn 1 --dtype bfloat16 --quant_type a8w8 --cachekv_int8_type static --use_fake_parameter 1
116
125
117
126
# 推理
118
- python -m paddle.distributed.launch --gpus " 0,1,2,3,4,5,6,7" predict/predictor.py --model_name_or_path /path/to/a8w8c8_tp8 --mode static --inference_model 1 --block_attn 1 --dtype bfloat16 --quant_type a8w8 --cachekv_int8_type static
127
+ python -m paddle.distributed.launch --gpus " 0,1,2,3,4,5,6,7" predict/predictor.py --model_name_or_path /path/to/a8w8c8_tp8 --mode static --inference_model 1 --block_attn 1 --dtype bfloat16 --quant_type a8w8 --cachekv_int8_type static
119
128
```
120
-
0 commit comments