Update README.md
Browse files
README.md
CHANGED
@@ -19,6 +19,33 @@ This model is a RetNet model trained from scratch using https://github.com/syncd
|
|
19 |
|
20 |
Demo: https://huggingface.co/spaces/p1atdev/LightNovel-Intro-RetNet-400M-Demo
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
## Model description
|
23 |
|
24 |
More information needed
|
|
|
19 |
|
20 |
Demo: https://huggingface.co/spaces/p1atdev/LightNovel-Intro-RetNet-400M-Demo
|
21 |
|
22 |
+
## Usage
|
23 |
+
|
24 |
+
```py
|
25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
26 |
+
|
27 |
+
MODEL_NAME = "p1atdev/LightNovel-Intro-RetNet-400M"
|
28 |
+
|
29 |
+
device = "cuda"
|
30 |
+
|
31 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
32 |
+
model = AutoModelForCausalLM.from_pretrained(
|
33 |
+
MODEL_NAME,
|
34 |
+
trust_remote_code=True,
|
35 |
+
).to(device)
|
36 |
+
gen_config = GenerationConfig.from_pretrained(MODEL_NAME)
|
37 |
+
gen_config.max_new_tokens = 32
|
38 |
+
|
39 |
+
inputs = tokenizer("็ฎใ่ฆใใใจใ", return_tensors="pt", add_special_tokens=False).to(device)
|
40 |
+
|
41 |
+
print("Generating...")
|
42 |
+
|
43 |
+
result = model.generate(**inputs, generation_config=gen_config)
|
44 |
+
|
45 |
+
print(tokenizer.decode(result[0], skip_special_tokens=True))
|
46 |
+
# ็ฎใ่ฆใใใจใ่ฆ็ฅใใฌ็ฉบ้ใซๅฑ
ใใ ใใ......?ใ ๆใใใใใชๅฃฐใๅบใใใจใซ้ๅๆใๆใใใ็ขบใใๆฐไปใใฐ็งใฏ
|
47 |
+
```
|
48 |
+
|
49 |
## Model description
|
50 |
|
51 |
More information needed
|