Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
+
智鹿是一个基于中文Alpaca2-13B进行二次训练的金融大模型,我们使用大量中英文语料进行增量预训练,同时使用高质量指令数据进行对齐。模型训练的目标是在保持通用能力的前提下,显著提升金融领域的能力。具体细节参考:[智鹿]()
|
5 |
+
|
6 |
+
# zhilu-LoRA-13B
|
7 |
+
|
8 |
+
本项目提供智鹿的`LoRA模块`,提供给已有`Alpaca-2-13B`模型的用户。
|
9 |
+
|
10 |
+
用户在使用前,可使用`peft库`进行加载,或与`Alpaca-2-13B`进行合并得到完整模型。
|
11 |
+
|
12 |
+
# 快速使用
|
13 |
+
|
14 |
+
```python
|
15 |
+
import torch
|
16 |
+
from transformers import LlamaForCausalLM, LlamaTokenizer
|
17 |
+
from peft import PeftModel
|
18 |
+
model_name_or_path = ""
|
19 |
+
peft_model_path = ""
|
20 |
+
tokenizer = LlamaTokenizer.from_pretrained(model_name_or_path, use_fast=False, legacy=True)
|
21 |
+
model = LlamaForCausalLM.from_pretrained(model_name_or_path, torch_dtype=torch.bfloat16,device_map="auto")
|
22 |
+
if peft_model_path is not None:
|
23 |
+
model = PeftModel.from_pretrained(
|
24 |
+
model,
|
25 |
+
peft_model_path,
|
26 |
+
torch_dtype=(
|
27 |
+
torch.bfloat16
|
28 |
+
if torch.cuda.is_bf16_supported()
|
29 |
+
else torch.float32
|
30 |
+
),
|
31 |
+
)
|
32 |
+
inputs = tokenizer("什么是A股?", return_tensors="pt").to("cuda")
|
33 |
+
outputs = model.generate(**inputs, max_new_tokens=64, repetition_penalty=1.1)
|
34 |
+
outputs = tokenizer.decode(outputs.cpu()[0][len(inputs.input_ids[0]):], skip_special_tokens=True)
|
35 |
+
print(outputs)
|
36 |
+
```
|