Update README.md
Browse files
README.md
CHANGED
@@ -16,14 +16,22 @@ We opensource our **Aquila2** series, now including **Aquila2**, the base langua
|
|
16 |
|
17 |
The additional details of the Aquila model will be presented in the official technical report. Please stay tuned for updates on official channels.
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
## Base Model Performance
|
21 |
|
22 |
-
<br>
|
23 |
-
<p align="center">
|
24 |
-
<img src="base_metrics.jpeg" width="1024"/>
|
25 |
-
<p>
|
26 |
-
<br>
|
27 |
|
28 |
## Quick Start Aquila2-7B
|
29 |
|
@@ -32,34 +40,43 @@ Aquila2-7B is a base model that can be used for continuation.
|
|
32 |
|
33 |
```python
|
34 |
import torch
|
35 |
-
from transformers import
|
36 |
from transformers import BitsAndBytesConfig
|
37 |
|
38 |
-
device
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
quantization_config=BitsAndBytesConfig(
|
42 |
load_in_4bit=True,
|
43 |
bnb_4bit_use_double_quant=True,
|
44 |
bnb_4bit_quant_type="nf4",
|
45 |
bnb_4bit_compute_dtype=torch.bfloat16,
|
46 |
)
|
47 |
-
model = AutoModelForCausalLM.from_pretrained(
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
model.eval()
|
|
|
51 |
model.to(device)
|
52 |
-
|
|
|
|
|
53 |
tokens = tokenizer.encode_plus(text)['input_ids']
|
54 |
tokens = torch.tensor(tokens)[None,].to(device)
|
55 |
-
|
56 |
with torch.no_grad():
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
```
|
61 |
|
62 |
|
63 |
## License
|
64 |
|
65 |
-
Aquila2 series open-source model is licensed under [ BAAI Aquila Model Licence Agreement](https://huggingface.co/BAAI/Aquila2-7B/blob/main/BAAI-Aquila-Model-License%20-Agreement.pdf)
|
|
|
16 |
|
17 |
The additional details of the Aquila model will be presented in the official technical report. Please stay tuned for updates on official channels.
|
18 |
|
19 |
+
## Updates 2024.6.6
|
20 |
+
|
21 |
+
We have updated the basic language model **Aquila2-7B**, which has the following advantages compared to the previous model:
|
22 |
+
|
23 |
+
* Replaced tokenizer with higher compression ratio:
|
24 |
+
|
25 |
+
| Tokenizer | Size | Zh | En | Code | Math | Average |
|
26 |
+
|-----------|-------|--------------------------|--------|-------|-------|---------|
|
27 |
+
| Aquila2-original | 100k | **4.70** | 4.42 | 3.20 | 3.77 | 4.02 |
|
28 |
+
| Qwen1.5 | 151k | 4.27 | 4.51 | 3.62 | 3.35 | 3.94 |
|
29 |
+
| Llama3 | 128k | 3.45 | **4.61** | 3.77 | **3.88** | 3.93 |
|
30 |
+
| Aquila2-new | 143k | 4.60 | **4.61** | **3.78** | **3.88** | **4.22** |
|
31 |
+
|
32 |
+
* The maximum processing length supported by the model has increased from 2048 to 8192
|
33 |
|
|
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
## Quick Start Aquila2-7B
|
37 |
|
|
|
40 |
|
41 |
```python
|
42 |
import torch
|
43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
44 |
from transformers import BitsAndBytesConfig
|
45 |
|
46 |
+
device= "cuda:0"
|
47 |
+
|
48 |
+
# Model Name
|
49 |
+
model_name = 'BAAI/Aquila2-7B'
|
50 |
+
|
51 |
+
# load model and tokenizer
|
52 |
quantization_config=BitsAndBytesConfig(
|
53 |
load_in_4bit=True,
|
54 |
bnb_4bit_use_double_quant=True,
|
55 |
bnb_4bit_quant_type="nf4",
|
56 |
bnb_4bit_compute_dtype=torch.bfloat16,
|
57 |
)
|
58 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, trust_remote_code=True,
|
59 |
+
# quantization_config=quantization_config # Uncomment this one for 4-bit quantization
|
60 |
+
)
|
61 |
+
|
62 |
+
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
63 |
+
|
64 |
model.eval()
|
65 |
+
|
66 |
model.to(device)
|
67 |
+
|
68 |
+
# Example
|
69 |
+
text = "The meaning of life is"
|
70 |
tokens = tokenizer.encode_plus(text)['input_ids']
|
71 |
tokens = torch.tensor(tokens)[None,].to(device)
|
72 |
+
|
73 |
with torch.no_grad():
|
74 |
+
out = llama.generate(tokens, do_sample=False, max_length=128, eos_token_id=tokenizer.eos_token_id)[0]
|
75 |
+
out = tokenizer.decode(out.cpu().numpy().tolist())
|
76 |
+
print(out)
|
77 |
```
|
78 |
|
79 |
|
80 |
## License
|
81 |
|
82 |
+
Aquila2 series open-source model is licensed under [ BAAI Aquila Model Licence Agreement](https://huggingface.co/BAAI/Aquila2-7B/blob/main/BAAI-Aquila-Model-License%20-Agreement.pdf)
|