Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
thumbnail: >-
|
5 |
+
https://s3.amazonaws.com/moonup/production/uploads/1677459920577-63b8e3432adad59f41dc65f4.jpeg?w=200&h=200&f=face
|
6 |
+
tags:
|
7 |
+
- bloom
|
8 |
+
license: bigscience-bloom-rail-1.0
|
9 |
+
pipeline_tag: text-generation
|
10 |
+
widget:
|
11 |
+
- text:问:真昼是谁?\n答:
|
12 |
+
---
|
13 |
+
|
14 |
+
# Bloom 7B1 LightNovel ZH_CN LoRa Finetuned
|
15 |
+
|
16 |
+
|
17 |
+
BigScience Large Open-science Open-access Multilingual Language Model with 7,1 billion parameters finetuned on Chinese Translation of Japanese LightNovel using LoRa from PEFT (?)
|
18 |
+
|
19 |
+
## Model Details
|
20 |
+
|
21 |
+
I just downloaded 50 LightNovels then finetuned the model on raw text.
|
22 |
+
|
23 |
+
Trained by Rorical
|
24 |
+
|
25 |
+
## Use
|
26 |
+
|
27 |
+
```python
|
28 |
+
import torch
|
29 |
+
from peft import PeftModel, PeftConfig
|
30 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
31 |
+
|
32 |
+
peft_model_id = "Rorical/bloom-7b1-lightnovel-lora"
|
33 |
+
config = PeftConfig.from_pretrained(peft_model_id)
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=True, device_map='auto', cache_dir="cache")
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, cache_dir="cache")
|
36 |
+
model = PeftModel.from_pretrained(model, peft_model_id, cache_dir="cache")
|
37 |
+
|
38 |
+
prompt = "你是谁?\n"
|
39 |
+
batch = tokenizer(prompt, return_tensors='pt').to("cuda")
|
40 |
+
|
41 |
+
with torch.cuda.amp.autocast():
|
42 |
+
output_tokens = model.generate(**batch, max_new_tokens=150, do_sample=True, top_k=50, top_p=0.95)
|
43 |
+
|
44 |
+
print(tokenizer.decode(output_tokens[0], skip_special_tokens=True))
|
45 |
+
```
|