RichardErkhov
commited on
uploaded readme
Browse files
README.md
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
Qwen1.5-MoE-A2.7B-Chat - bnb 4bits
|
11 |
+
- Model creator: https://huggingface.co/Qwen/
|
12 |
+
- Original model: https://huggingface.co/Qwen/Qwen1.5-MoE-A2.7B-Chat/
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
Original model description:
|
18 |
+
---
|
19 |
+
license: other
|
20 |
+
license_name: tongyi-qianwen
|
21 |
+
license_link: >-
|
22 |
+
https://huggingface.co/Qwen/Qwen1.5-MoE-A2.7B-Chat/blob/main/LICENSE
|
23 |
+
language:
|
24 |
+
- en
|
25 |
+
pipeline_tag: text-generation
|
26 |
+
tags:
|
27 |
+
- chat
|
28 |
+
---
|
29 |
+
|
30 |
+
# Qwen1.5-MoE-A2.7B-Chat
|
31 |
+
|
32 |
+
|
33 |
+
## Introduction
|
34 |
+
|
35 |
+
Qwen1.5-MoE is a transformer-based MoE decoder-only language model pretrained on a large amount of data.
|
36 |
+
|
37 |
+
For more details, please refer to our [blog post](https://qwenlm.github.io/blog/qwen-moe/) and [GitHub repo](https://github.com/QwenLM/Qwen1.5).
|
38 |
+
|
39 |
+
## Model Details
|
40 |
+
Qwen1.5-MoE employs Mixture of Experts (MoE) architecture, where the models are upcycled from dense language models. For instance, `Qwen1.5-MoE-A2.7B` is upcycled from `Qwen-1.8B`. It has 14.3B parameters in total and 2.7B activated parameters during runtime, while achieching comparable performance to `Qwen1.5-7B`, it only requires 25% of the training resources. We also observed that the inference speed is 1.74 times that of `Qwen1.5-7B`.
|
41 |
+
|
42 |
+
## Training details
|
43 |
+
We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
|
44 |
+
|
45 |
+
## Requirements
|
46 |
+
The code of Qwen1.5-MoE has been in the latest Hugging face transformers and we advise you to build from source with command `pip install git+https://github.com/huggingface/transformers`, or you might encounter the following error:
|
47 |
+
```
|
48 |
+
KeyError: 'qwen2_moe'.
|
49 |
+
```
|
50 |
+
|
51 |
+
## Quickstart
|
52 |
+
|
53 |
+
Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
|
54 |
+
|
55 |
+
```python
|
56 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
57 |
+
device = "cuda" # the device to load the model onto
|
58 |
+
|
59 |
+
model = AutoModelForCausalLM.from_pretrained(
|
60 |
+
"Qwen/Qwen1.5-MoE-A2.7B-Chat",
|
61 |
+
torch_dtype="auto",
|
62 |
+
device_map="auto"
|
63 |
+
)
|
64 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen1.5-MoE-A2.7B-Chat")
|
65 |
+
|
66 |
+
prompt = "Give me a short introduction to large language model."
|
67 |
+
messages = [
|
68 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
69 |
+
{"role": "user", "content": prompt}
|
70 |
+
]
|
71 |
+
text = tokenizer.apply_chat_template(
|
72 |
+
messages,
|
73 |
+
tokenize=False,
|
74 |
+
add_generation_prompt=True
|
75 |
+
)
|
76 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
77 |
+
|
78 |
+
generated_ids = model.generate(
|
79 |
+
model_inputs.input_ids,
|
80 |
+
max_new_tokens=512
|
81 |
+
)
|
82 |
+
generated_ids = [
|
83 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
84 |
+
]
|
85 |
+
|
86 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
87 |
+
```
|
88 |
+
|
89 |
+
For quantized models, we advise you to use the GPTQ correspondents, namely `Qwen1.5-MoE-A2.7B-Chat-GPTQ-Int4`.
|
90 |
+
|
91 |
+
|
92 |
+
## Tips
|
93 |
+
|
94 |
+
* If you encounter code switching or other bad cases, we advise you to use our provided hyper-parameters in `generation_config.json`.
|
95 |
+
*
|
96 |
+
|