Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c19eec

Browse filesBrowse files
airariaGoGoJoestar
andauthored
Add Speculative sampling support (#328)
* update readme * add speculative sample * update inference scripts about speculative sampling * update README.md * update readme * update readme * update readme * update readme * update HF links * Update speculative_sample.py * Update gradio_demo.py * Update README.md * Update README_EN.md * Update speculative_sample.py * Update speculative_sample.py * Update speculative_sample.py * Update speculative_sample.py * Update gradio_demo.py * fix bugs in speculative sampling --------- Co-authored-by: GoGoJoestar <qazxc59419@163.com> Co-authored-by: GoGoJoestar <58219543+GoGoJoestar@users.noreply.github.com>
1 parent 09eadc6 commit 0c19eec
Copy full SHA for 0c19eec

File tree

Expand file treeCollapse file tree

6 files changed

+790
-68
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+790
-68
lines changed
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+27-13Lines changed: 27 additions & 13 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
#### 已开源的模型
2626

27-
- 基座模型:Chinese-LLaMA-2-7B, Chinese-LLaMA-2-13B
28-
- 聊天模型:Chinese-Alpaca-2-7B, Chinese-Alpaca-2-13B
27+
- 基座模型:Chinese-LLaMA-2-1.3B, Chinese-LLaMA-2-7B, Chinese-LLaMA-2-13B
28+
- 聊天模型:Chinese-Alpaca-2-1.3B, Chinese-Alpaca-2-7B, Chinese-Alpaca-2-13B
2929
- 长上下文模型:Chinese-LLaMA-2-7B-16K, Chinese-LLaMA-2-13B-16K, Chinese-Alpaca-2-7B-16K, Chinese-Alpaca-2-13B-16K
3030

3131
![](./pics/screencast.gif)
@@ -101,9 +101,9 @@
101101
| 对比项 | 中文LLaMA-2 | 中文Alpaca-2 |
102102
| :-------------------- | :----------------------------------------------------: | :----------------------------------------------------------: |
103103
| 模型类型 | **基座模型** | **指令/Chat模型(类ChatGPT)** |
104-
| 已开源大小 | 7B、13B | 7B、13B |
104+
| 已开源大小 | 1.3B、7B、13B | 1.3B、7B、13B |
105105
| 训练类型 | Causal-LM (CLM) | 指令精调 |
106-
| 训练方式 | LoRA + 全量emb/lm-head | LoRA + 全量emb/lm-head |
106+
| 训练方式 | 7B、13B:LoRA + 全量emb/lm-head<br/>1.3B:全量 | 7B、13B:LoRA + 全量emb/lm-head<br/>1.3B:全量 |
107107
| 基于什么模型训练 | [原版Llama-2](https://github.com/facebookresearch/llama)(非chat版) | 中文LLaMA-2 |
108108
| 训练语料 | 无标注通用语料(120G纯文本) | 有标注指令数据(500万条) |
109109
| 词表大小<sup>[1]</sup> | 55,296 | 55,296 |
@@ -116,6 +116,7 @@
116116
> [1] *本项目一代模型和二代模型的词表不同,请勿混用。二代LLaMA和Alpaca的词表相同。*</br>
117117
> [2] *括号内表示基于NTK上下文扩展支持的最大长度。*</br>
118118
> [3] *Alpaca-2采用了Llama-2-chat系列模板(格式相同,提示语不同),而不是一代Alpaca的模板,请勿混用。*</br>
119+
> [4] *不建议单独使用1.3B模型,而是通过投机采样搭配更大的模型(7B、13B)使用。*</br>
119120
120121
### 完整模型下载
121122

@@ -125,8 +126,10 @@
125126
| :------------------------ | :------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
126127
| Chinese-LLaMA-2-13B | 基座模型 | 24.7 GB | [[百度]](https://pan.baidu.com/s/1T3RqEUSmyg6ZuBwMhwSmoQ?pwd=e9qy) [[Google]](https://drive.google.com/drive/folders/1YNa5qJ0x59OEOI7tNODxea-1YvMPoH05?usp=share_link) [[🤗HF]](https://huggingface.co/ziqingyang/chinese-llama-2-13b) |
127128
| Chinese-LLaMA-2-7B | 基座模型 | 12.9 GB | [[百度]](https://pan.baidu.com/s/1E5NI3nlQpx1j8z3eIzbIlg?pwd=n8k3) [[Google]](https://drive.google.com/drive/folders/18pp4I-mvQxRA7b8vF9gP-2cH_ocnXVKh?usp=share_link) [[🤗HF]](https://huggingface.co/ziqingyang/chinese-llama-2-7b) |
129+
| Chinese-LLaMA-2-1.3B | 基座模型 | 2.4 GB | [[🤗HF]](https://huggingface.co/ziqingyang/chinese-llama-2-1.3b) |
128130
| Chinese-Alpaca-2-13B | 指令模型 | 24.7 GB | [[百度]](https://pan.baidu.com/s/1MT_Zlap1OtdYMgoBNTS3dg?pwd=9xja) [[Google]](https://drive.google.com/drive/folders/1MTsKlzR61xmbTR4hBWzQas_MOpUZsogN?usp=share_link) [[🤗HF]](https://huggingface.co/ziqingyang/chinese-alpaca-2-13b) |
129131
| Chinese-Alpaca-2-7B | 指令模型 | 12.9 GB | [[百度]](https://pan.baidu.com/s/1wxx-CdgbMupXVRBcaN4Slw?pwd=kpn9) [[Google]](https://drive.google.com/drive/folders/1JsJDVs7tE2y31PBNleBlDPsB7S0ZrY8d?usp=share_link) [[🤗HF]](https://huggingface.co/ziqingyang/chinese-alpaca-2-7b) |
132+
| Chinese-Alpaca-2-1.3B | 指令模型 | 2.4 GB | [[🤗HF]](https://huggingface.co/ziqingyang/chinese-alpaca-2-1.3b) |
130133

131134
以下是长上下文版模型,**推荐以长文本为主的下游任务使用**,否则建议使用上述标准版。
132135

@@ -172,15 +175,15 @@
172175

173176
本项目中的相关模型主要支持以下量化、推理和部署方式,具体内容请参考对应教程。
174177

175-
| 工具 | 特点 | CPU | GPU | 量化 | GUI | API | vLLM<sup>§</sup> | 16K<sup>‡</sup> | 教程 |
176-
| :----------------------------------------------------------- | ---------------------------- | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: |
177-
| [**llama.cpp**](https://github.com/ggerganov/llama.cpp) | 丰富的量化选项和高效本地推理 |||||||| [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/llamacpp_zh) |
178-
| [**🤗Transformers**](https://github.com/huggingface/transformers) | 原生transformers推理接口 |||||||| [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/inference_with_transformers_zh) |
179-
| [**Colab Demo**](https://colab.research.google.com/drive/1yu0eZ3a66by8Zqm883LLtRQrguBAb9MR?usp=sharing) | 在Colab中启动交互界面 |||||||| [link](https://colab.research.google.com/drive/1yu0eZ3a66by8Zqm883LLtRQrguBAb9MR?usp=sharing) |
180-
| [**仿OpenAI API调用**](https://platform.openai.com/docs/api-reference) | 仿OpenAI API接口的服务器Demo |||||||| [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/api_calls_zh) |
181-
| [**text-generation-webui**](https://github.com/oobabooga/text-generation-webui) | 前端Web UI界面的部署方式 ||||| ✅<sup>†</sup> ||| [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/text-generation-webui_zh) |
182-
| [**LangChain**](https://github.com/hwchase17/langchain) | 适合二次开发的大模型应用开源框架 | ✅<sup>†</sup> || ✅<sup>†</sup> ||||| [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/langchain_zh) |
183-
| [**privateGPT**](https://github.com/imartinez/privateGPT) | 基于LangChain的多文档本地问答框架 |||||||| [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/privategpt_zh) |
178+
| 工具 | 特点 | CPU | GPU | 量化 | GUI | API | vLLM<sup>§</sup> | 16K<sup>‡</sup> | 投机采样 | 教程 |
179+
| :----------------------------------------------------------- | ---------------------------- | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: |
180+
| [**llama.cpp**](https://github.com/ggerganov/llama.cpp) | 丰富的量化选项和高效本地推理 |||||||| | [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/llamacpp_zh) |
181+
| [**🤗Transformers**](https://github.com/huggingface/transformers) | 原生transformers推理接口 |||||||| | [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/inference_with_transformers_zh) |
182+
| [**Colab Demo**](https://colab.research.google.com/drive/1yu0eZ3a66by8Zqm883LLtRQrguBAb9MR?usp=sharing) | 在Colab中启动交互界面 |||||||| | [link](https://colab.research.google.com/drive/1yu0eZ3a66by8Zqm883LLtRQrguBAb9MR?usp=sharing) |
183+
| [**仿OpenAI API调用**](https://platform.openai.com/docs/api-reference) | 仿OpenAI API接口的服务器Demo |||||||| | [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/api_calls_zh) |
184+
| [**text-generation-webui**](https://github.com/oobabooga/text-generation-webui) | 前端Web UI界面的部署方式 ||||| ✅<sup>†</sup> ||| | [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/text-generation-webui_zh) |
185+
| [**LangChain**](https://github.com/hwchase17/langchain) | 适合二次开发的大模型应用开源框架 | ✅<sup>†</sup> || ✅<sup>†</sup> ||||| | [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/langchain_zh) |
186+
| [**privateGPT**](https://github.com/imartinez/privateGPT) | 基于LangChain的多文档本地问答框架 |||||||| | [link](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/privategpt_zh) |
184187

185188
> [!NOTE]
186189
> <sup>†</sup> 工具支持该特性,但教程中未实现,详细说明请参考对应官方文档<br/>
@@ -273,6 +276,17 @@
273276
| CPU Speed | 117 | 42 | 51 | 39 | 44 | 43 | 48 | 51 | 50 | 54 | 65 |
274277
| GPU Speed | 53 | 19 | 21 | 17 | 18 | 20 | x | x | 25 | 26 | x |
275278

279+
### 投机采样加速效果评测
280+
281+
通过投机采样方法并借助Chinese-LLaMA-2-1.3B和Chinese-Alpaca-2-1.3B,可以分别加速7B、13B的LLaMA和Alpaca模型的推理速度。以下是使用[投机采样脚本](scripts/inference/speculative_sample.py)在1*A40-48G上解码[生成效果评测](#生成效果评测)中的问题测得的平均速度(速度以ms/token计,模型均为fp16精度),供用户参考。详细说明见[📖GitHub Wiki](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2/wiki/inference_with_transformers_zh#投机采样解码)
282+
283+
| 草稿模型 | 草稿模型速度 | 目标模型 | 目标模型速度 | 投机采样速度(加速比) |
284+
| :---------- | :-----------------: | :----------- | :-----------------: | :--------: |
285+
| Chinese-LLaMA-2-1.3B | 7.6 | Chinese-LLaMA-2-7B | 49.3 | 36.0(1.37x) |
286+
| Chinese-LLaMA-2-1.3B | 7.6 | Chinese-LLaMA-2-13B | 66.0 | 47.1(1.40x) |
287+
| Chinese-Alpaca-2-1.3B | 8.1 | Chinese-Alpaca-2-7B | 50.2 | 34.9(1.44x) |
288+
| Chinese-Alpaca-2-1.3B | 8.2 | Chinese-Alpaca-2-13B | 67.0 | 41.6(1.61x) |
289+
276290
## 训练与精调
277291

278292
### 预训练

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.