Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
|
5 |
+
# BiLLa: A Bilingual LLaMA with Enhanced Reasoning Ability
|
6 |
+
|
7 |
+
BiLLa is an open-source reasoning-enhanced bilingual LLaMA model. The main features are:
|
8 |
+
- Greatly improve the ability of Chinese language modeling, and minimize the damage to the original English ability of LLaMA;
|
9 |
+
- During the training, more task data is added with ChatGPT-generated analysis;
|
10 |
+
- Full-parameter optimization for better performance.
|
11 |
+
|
12 |
+
Github: https://github.com/Neutralzz/BiLLa
|
13 |
+
|
14 |
+
<b>Note</b>: Due to LLaMA's license, the model weights in this hub cannot be used directly.
|
15 |
+
The weight of `word embedding` is the sum of the weights of the trained model and the original LLaMA,
|
16 |
+
so as to ensure that developers with LLaMA original model accessibility can convert the model released by this hub into a usable one.
|
17 |
+
|
18 |
+
First, you can revert the model weights by [this script](https://github.com/Neutralzz/BiLLa/blob/main/embedding_convert.py):
|
19 |
+
```shell
|
20 |
+
python3 embedding_convert.py \
|
21 |
+
--model_dir /path_to_BiLLa/BiLLa-7B-LLM \
|
22 |
+
--meta_llama_pth_file /path_to_LLaMA/llama-7b/consolidated.00.pth
|
23 |
+
```
|
24 |
+
|
25 |
+
Then, you can run this model as follows:
|
26 |
+
```python
|
27 |
+
import torch
|
28 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
29 |
+
model_path = "/path_to_BiLLa/BiLLa-7B-LLM"
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
|
31 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, torch_dtype=torch.float16).cuda()
|
32 |
+
|
33 |
+
prompt = "[Your prompt]"
|
34 |
+
input_ids = tokenizer([prompt]).input_ids
|
35 |
+
output_ids = model.generate(
|
36 |
+
torch.as_tensor(input_ids).cuda(),
|
37 |
+
do_sample=True,
|
38 |
+
temperature=0.7,
|
39 |
+
max_new_tokens=1024
|
40 |
+
)
|
41 |
+
output_ids = output_ids[0][len(input_ids[0]):]
|
42 |
+
|
43 |
+
outputs = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
|
44 |
+
print(outputs)
|
45 |
+
```
|
46 |
+
|
47 |
+
Different from [BiLLa-7B-SFT](https://huggingface.co/Neutralzz/BiLLa-7B-SFT), the input format of `BiLLa-7B-LLM` has no restriction.
|