p1atdev commited on
Commit
9ce9778
โ€ข
1 Parent(s): 13bad7a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -0
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