Neutralzz commited on
Commit
8f2161d
1 Parent(s): 2d2e0f7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -11
README.md CHANGED
@@ -1,35 +1,36 @@
1
  ---
2
  license: apache-2.0
3
- pipeline_tag: text-generation
4
  ---
5
 
6
  # BiLLa: A Bilingual LLaMA with Enhanced Reasoning Ability
7
 
8
- BiLLa是开源的推理能力增强的中英双语LLaMA模型。模型的主要特性有:
9
- - 较大提升LLaMA的中文理解能力,并尽可能减少对原始LLaMA英文能力的损伤;
10
- - 训练过程增加较多的任务型数据,利用ChatGPT生成解析,强化模型理解任务求解逻辑;
11
- - 全量参数更新,追求更好的生成效果。
12
 
13
  Github: https://github.com/Neutralzz/BiLLa
14
 
15
- <b>注意</b>:因为LLaMA的License限制,本项目开放的模型权重并不能直接使用。开放的模型权重中`word embedding`的权重为训练后模型的权重和原始LLaMA权重的和,从而保证拥有LLaMA原始模型授权的开发者可以将本项目发布的模型转化成可以使用的格式。
 
 
16
 
17
- 拥有LLaMA原始模型的开发者可以通过本项目Github中的脚本`embedding_convert.py`完成BiLLa模型权重的还原,以下为示例:
18
  ```shell
19
  python3 embedding_convert.py \
20
  --model_dir /path_to_BiLLa/BiLLa-7B-SFT \
21
  --meta_llama_pth_file /path_to_LLaMA/llama-7b/consolidated.00.pth
22
  ```
23
 
24
- BiLLa-7B-SFT模型权重还原后,可通过以下代码调试运行:
25
  ```python
26
  import torch
27
  from transformers import AutoTokenizer, AutoModelForCausalLM
28
- model_path = "/path_to_billa"
29
  tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
30
  model = AutoModelForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, torch_dtype=torch.float16).cuda()
31
 
32
- prompt = "Human: Python写一个冒泡排序算法\nAssistant: "
33
  input_ids = tokenizer([prompt]).input_ids
34
  output_ids = model.generate(
35
  torch.as_tensor(input_ids).cuda(),
@@ -43,7 +44,7 @@ outputs = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
43
  print(outputs)
44
  ```
45
 
46
- BiLLa-7B-SFT的模型输入需按以下格式构造(注意`Assistant:`后必须有一个空格):
47
  ```
48
  Human: [Your question]
49
  Assistant:
 
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-SFT \
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-SFT"
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 = "Human: Write a Python function that checks if a given number is even or odd.\nAssistant: "
34
  input_ids = tokenizer([prompt]).input_ids
35
  output_ids = model.generate(
36
  torch.as_tensor(input_ids).cuda(),
 
44
  print(outputs)
45
  ```
46
 
47
+ Different from [BiLLa-7B-LLM](https://huggingface.co/Neutralzz/BiLLa-7B-LLM), the model input of `BiLLa-7B-SFT` should be formatted as follows (note that a space is following the `Assistant:`):
48
  ```
49
  Human: [Your question]
50
  Assistant: