Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: creativeml-openrail-m
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- LLM
|
| 7 |
+
- tensorRT
|
| 8 |
+
- Belle
|
| 9 |
+
---
|
| 10 |
+
## Model Card for lyraBelle
|
| 11 |
+
|
| 12 |
+
lyraBelle is currently the **fastest Belle model** available. To the best of our knowledge, it is the **first accelerated version of ChatGLM-6B**.
|
| 13 |
+
|
| 14 |
+
The inference speed of lyraChatGLM has achieved **10x** acceleration upon the ealry original version. We are still working hard to further improve the performance.
|
| 15 |
+
|
| 16 |
+
Among its main features are:
|
| 17 |
+
|
| 18 |
+
- weights: original BELLE-7B-2M weights released by BelleGroup.
|
| 19 |
+
- device: Any
|
| 20 |
+
- batch_size: compiled with dynamic batch size, max batch_size = 8
|
| 21 |
+
|
| 22 |
+
## Speed
|
| 23 |
+
|
| 24 |
+
### test environment
|
| 25 |
+
|
| 26 |
+
- device: Nvidia A100 40G
|
| 27 |
+
- batch size: 8
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|version|speed|
|
| 31 |
+
|:-:|:-:|
|
| 32 |
+
|original|30 tokens/s|
|
| 33 |
+
|lyraBelle|310 tokens/s|
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
## Model Sources
|
| 37 |
+
|
| 38 |
+
- **Repository:** [https://huggingface.co/BelleGroup/BELLE-7B-2M?clone=true]
|
| 39 |
+
|
| 40 |
+
## Try Demo in 2 fast steps
|
| 41 |
+
|
| 42 |
+
``` bash
|
| 43 |
+
#step 1
|
| 44 |
+
git clone https://huggingface.co/TMElyralab/lyraChatGLM
|
| 45 |
+
cd lyraChatGLM
|
| 46 |
+
|
| 47 |
+
#step 2
|
| 48 |
+
docker run --gpus=1 --rm --net=host -v ${PWD}:/workdir yibolu96/lyra-chatglm-env:0.0.1 python3 /workdir/demo.py
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## Uses
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
from transformers import AutoTokenizer
|
| 55 |
+
from faster_chat_glm import GLM6B, FasterChatGLM
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
MAX_OUT_LEN = 100
|
| 59 |
+
tokenizer = AutoTokenizer.from_pretrained('./models', trust_remote_code=True)
|
| 60 |
+
input_str = ["为什么我们需要对深度学习模型加速?", ]
|
| 61 |
+
inputs = tokenizer(input_str, return_tensors="pt", padding=True)
|
| 62 |
+
input_ids = inputs.input_ids.to('cuda:0')
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
plan_path = './models/glm6b-bs8.ftm'
|
| 66 |
+
# kernel for chat model.
|
| 67 |
+
kernel = GLM6B(plan_path=plan_path,
|
| 68 |
+
batch_size=1,
|
| 69 |
+
num_beams=1,
|
| 70 |
+
use_cache=True,
|
| 71 |
+
num_heads=32,
|
| 72 |
+
emb_size_per_heads=128,
|
| 73 |
+
decoder_layers=28,
|
| 74 |
+
vocab_size=150528,
|
| 75 |
+
max_seq_len=MAX_OUT_LEN)
|
| 76 |
+
|
| 77 |
+
chat = FasterChatGLM(model_dir="./models", kernel=kernel).half().cuda()
|
| 78 |
+
|
| 79 |
+
# generate
|
| 80 |
+
sample_output = chat.generate(inputs=input_ids, max_length=MAX_OUT_LEN)
|
| 81 |
+
# de-tokenize model output to text
|
| 82 |
+
res = tokenizer.decode(sample_output[0], skip_special_tokens=True)
|
| 83 |
+
print(res)
|
| 84 |
+
```
|
| 85 |
+
## Demo output
|
| 86 |
+
|
| 87 |
+
### input
|
| 88 |
+
为什么我们需要对深度学习模型加速? 。
|
| 89 |
+
|
| 90 |
+
### output
|
| 91 |
+
为什么我们需要对深度学习模型加速? 深度学习模型的训练需要大量计算资源,特别是在训练模型时,需要大量的内存、GPU(图形处理器)和其他计算资源。因此,训练深度学习模型需要一定的时间,并且如果模型不能快速训练,则可能会导致训练进度缓慢或无法训练。
|
| 92 |
+
|
| 93 |
+
以下是一些原因我们需要对深度学习模型加速:
|
| 94 |
+
|
| 95 |
+
1. 训练深度神经网络需要大量的计算资源,特别是在训练深度神经网络时,需要更多的计算资源,因此需要更快的训练速度。
|
| 96 |
+
|
| 97 |
+
### TODO:
|
| 98 |
+
|
| 99 |
+
We plan to implement a FasterTransformer version to publish a much faster release. Stay tuned!
|
| 100 |
+
|
| 101 |
+
## Citation
|
| 102 |
+
``` bibtex
|
| 103 |
+
@Misc{lyraChatGLM2023,
|
| 104 |
+
author = {Kangjian Wu, Zhengtao Wang, Bin Wu},
|
| 105 |
+
title = {lyraChatGLM: Accelerating ChatGLM by 10x+},
|
| 106 |
+
howpublished = {\url{https://huggingface.co/TMElyralab/lyraChatGLM}},
|
| 107 |
+
year = {2023}
|
| 108 |
+
}
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
## Report bug
|
| 112 |
+
- start a discussion to report any bugs!--> https://huggingface.co/TMElyralab/lyraChatGLM/discussions
|
| 113 |
+
- report bug with a `[bug]` mark in the title.
|