Kohsaku commited on
Commit
0606b64
·
verified ·
1 Parent(s): 126892e

update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -0
README.md CHANGED
@@ -20,3 +20,37 @@ language:
20
  This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
23
+
24
+ from unsloth import FastLanguageModel
25
+ import torch
26
+ import json
27
+
28
+ ```
29
+ model_name = "Kohsaku/llm-jp-3-13b-finetune-5"
30
+
31
+ max_seq_length = 2048
32
+ dtype = None
33
+ load_in_4bit = True
34
+
35
+ model, tokenizer = FastLanguageModel.from_pretrained(
36
+ model_name = model_name,
37
+ max_seq_length = max_seq_length,
38
+ dtype = dtype,
39
+ load_in_4bit = load_in_4bit,
40
+ token = HF_TOKEN,
41
+ )
42
+ FastLanguageModel.for_inference(model)
43
+
44
+ text = "自然言語処理とは何か"
45
+ tokenized_input = tokenizer.encode(text, add_special_tokens=False, return_tensors="pt").to(model.device)
46
+ with torch.no_grad():
47
+ output = model.generate(
48
+ tokenized_input,
49
+ max_new_tokens = 512,
50
+ use_cache = True,
51
+ do_sample=False,
52
+ repetition_penalty=1.2
53
+ )[0]
54
+
55
+ print(tokenizer.decode(output))
56
+ ```