Create README.md
Browse files
README.md
CHANGED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- anon8231489123/ShareGPT_Vicuna_unfiltered
|
5 |
+
- PengQu/langchain-MRKL-finetune
|
6 |
+
language:
|
7 |
+
- zh
|
8 |
+
- en
|
9 |
+
---
|
10 |
+
# open_llama_7b_v2_vicuna_Chinese
|
11 |
+
|
12 |
+
open_llama_7b_v2_vicuna_Chinese是在中英双语sharegpt数据上全参数微调的对话模型。
|
13 |
+
|
14 |
+
- 基座模型:[open_llama_7b_v2](https://huggingface.co/openlm-research/open_llama_7b_v2), 允许商业使用。
|
15 |
+
- 微调数据:ShareGPT,ShareGPT-ZH,Langchain-MRKL-finetune
|
16 |
+
- 训练代码:基于[FastChat](https://github.com/lm-sys/FastChat)
|
17 |
+
|
18 |
+
open_llama_7b_v2_vicuna_Chinese is a chat model supervised finetuned on vicuna sharegpt data in both **English** and **Chinese**.
|
19 |
+
|
20 |
+
- Foundation model: [open_llama_7b_v2](https://huggingface.co/openlm-research/open_llama_7b_v2), a **commercially available** language model.
|
21 |
+
- Finetuning data: ShareGPT,ShareGPT-ZH,Langchain-MRKL-finetune
|
22 |
+
- Training code: based on [FastChat](https://github.com/lm-sys/FastChat)
|
23 |
+
|
24 |
+
## Loading the Weights with Hugging Face Transformers
|
25 |
+
**Please note that it is advised to avoid using the Hugging Face fast tokenizer for now, as we’ve observed that** [**the auto-converted fast tokenizer sometimes gives incorrect tokenizations**](https://github.com/huggingface/transformers/issues/24233)**.** This can be achieved by directly using the `LlamaTokenizer` class, or passing in the `use_fast=False` option for the `AutoTokenizer` class. See the following example for usage.
|
26 |
+
|
27 |
+
```python
|
28 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
29 |
+
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained("PengQu/open_llama_7b_v2_vicuna_Chinese",use_fast=False)
|
31 |
+
model = AutoModelForCausalLM.from_pretrained("PengQu/open_llama_7b_v2_vicuna_Chinese").to("cuda:6")
|
32 |
+
|
33 |
+
prompt = '用flask写一个简单的http服务器。'
|
34 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to("cuda:6")
|
35 |
+
|
36 |
+
generation_output = model.generate(input_ids=input_ids, max_new_tokens=512)
|
37 |
+
print(tokenizer.decode(generation_output[0],skip_special_tokens=True))
|
38 |
+
```
|
39 |
+
|
40 |
+
输出如下(output as follows):<br>
|
41 |
+
```
|
42 |
+
用flask写一个简单的http服务器。
|
43 |
+
|
44 |
+
from flask import Flask
|
45 |
+
app = Flask(__name__)
|
46 |
+
@app.route('/')
|
47 |
+
def hello():
|
48 |
+
return 'Hello, World!'
|
49 |
+
if __name__ == '__main__':
|
50 |
+
app.run()
|
51 |
+
|
52 |
+
这段代码定义了一个Flask应用程序,并为根路径('/')定义了一个路由。当用户在其Web浏览器中导航到该路径时,将调用`hello()`函数,并返回字符串“Hello, World!”。
|
53 |
+
要运行此代码,您需要在计算机上安装Flask。您可以使用以下命令使用pip安装它:
|
54 |
+
|
55 |
+
pip install Flask
|
56 |
+
|
57 |
+
安装Flask后,您可以使用以下命令运行代码:
|
58 |
+
|
59 |
+
python app.py
|
60 |
+
|
61 |
+
这将启动一个本地开发服务器,您可以使用Web浏览器访问它,方法是导航到`http://localhost:5000/`。
|
62 |
+
您还可以通过添加其他路由和功能来进一步自定义代码。例如,您可以为不同的端点定义不同的路由,并使用请求数据执行某些操作。您还可以向应用程序添加错误处理和用户身份验证。
|
63 |
+
```
|
64 |
+
## Major Improvement
|
65 |
+
- 基于open_llama_7b_v2训练,完全允许商业使用
|
66 |
+
- 英语效果与vicuna-7b持平,中文效果好于vicuna-7b
|
67 |
+
- 编程能力好于vicuna-7b,应该是open_llama_7b_v2用了StarCoder数据集
|
68 |
+
- 支持langchain-MRKL格式(agent= "zero-shot-react-description")
|
69 |
+
<br>
|
70 |
+
- Finetuned on openllama, allowing for commercial purposes.
|
71 |
+
- Achieves the same level of English performance as vicuna-7b and outperforms vicuna-7b in Chinese performance
|
72 |
+
- Has better programming ability than vicuna-7b, likely due to the use of the StarCoder dataset in open_llama_7b_v2
|
73 |
+
- Supports langchain-MRKL format(agent= "zero-shot-react-description").
|
74 |
+
|