msfm commited on
Commit
af77d8f
·
verified ·
1 Parent(s): b24bda0

Add an example

Browse files
Files changed (1) hide show
  1. README.md +22 -0
README.md CHANGED
@@ -20,3 +20,25 @@ 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
+ # Example
25
+
26
+ ``` python
27
+ from unsloth import FastLanguageModel
28
+
29
+ model, tokenizer = FastLanguageModel.from_pretrained(
30
+ model_name="msfm/llm-jp-3-13b-ichikara_all",
31
+ dtype=dtype,
32
+ load_in_4bit=True,
33
+ trust_remote_code=True,
34
+ )
35
+ FastLanguageModel.for_inference(model)
36
+
37
+ input = "野球選手が今シーズン活躍するために取り組むべき5つのことを教えてください。"
38
+
39
+ prompt = f"""### 指示\n{input}\n### 回答\n"""
40
+
41
+ inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
42
+ outputs = model.generate(**inputs, max_new_tokens = 2048, use_cache = True, do_sample=False, repetition_penalty=1.2)
43
+ prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
44
+ ```