Update README.md
Browse files
README.md
CHANGED
@@ -7,7 +7,22 @@ tags:
|
|
7 |
- not-for-all-audiences
|
8 |
---
|
9 |
|
10 |
-
数据来源自[h-corpus-2023](https://huggingface.co/a686d380/h-corpus-2023)
|
11 |
模型来源自[Qwen1.5-0.5B](https://huggingface.co/Qwen/Qwen1.5-0.5B)
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
- not-for-all-audiences
|
8 |
---
|
9 |
|
10 |
+
数据来源自[h-corpus-2023](https://huggingface.co/datasets/a686d380/h-corpus-2023)
|
11 |
模型来源自[Qwen1.5-0.5B](https://huggingface.co/Qwen/Qwen1.5-0.5B)
|
12 |
|
13 |
+
本模型仅用于学术研究或个人学习,严禁商用。
|
14 |
+
|
15 |
+
```
|
16 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
17 |
+
|
18 |
+
repo_id = 'Monor/Qwen1.5-0.5B-h-world'
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True)
|
20 |
+
model = AutoModelForCausalLM.from_pretrained(repo_id, device_map="auto", trust_remote_code=True).eval()
|
21 |
+
|
22 |
+
inputs = tokenizer('小青突然来到了我的房间', return_tensors='pt')
|
23 |
+
inputs = inputs.to(model.device)
|
24 |
+
pred = model.generate(**inputs, max_new_tokens=32, num_beams=4, do_sample=True)
|
25 |
+
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
|
26 |
+
|
27 |
+
输出:小青突然来到了我的房间,吓了我一跳。她见我睡着了,就脱了衣服钻进了被窝里,然后搂着我睡着了。
|
28 |
+
```
|