Kendamarron
commited on
Commit
•
0583491
1
Parent(s):
4552afc
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,44 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- ja
|
5 |
---
|
6 |
+
## モデルについて
|
7 |
+
与えられたテキストに関連するinstructionを生成するモデルです。
|
8 |
+
|
9 |
+
instructionデータセット作成にお役立てください。
|
10 |
+
|
11 |
+
不適切なinstructionが生成される可能性がありますので、出力のチェックは必須です。
|
12 |
+
|
13 |
+
詳細については[こちら](https://zenn.dev/kendama/articles/85ed50d31207bf)をご覧ください。
|
14 |
+
|
15 |
+
## 使い方
|
16 |
+
|
17 |
+
```python
|
18 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
19 |
+
from peft import PeftModel
|
20 |
+
model_path = "Rakuten/RakutenAI-7B-instruct"
|
21 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
22 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16, device_map="auto")
|
23 |
+
model = PeftModel.from_pretrained(
|
24 |
+
model,
|
25 |
+
"Kendamarron/jimba-instruction-generator_RakutenAI-7B-instruct_lora"
|
26 |
+
)
|
27 |
+
model.eval()
|
28 |
+
input_text = "サンプルテキスト"
|
29 |
+
system_message = """A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: 次の要素を使った算数の文章問題を作成してください。
|
30 |
+
要素: {user_input} ASSISTANT: """
|
31 |
+
inputs = tokenizer(system_message.format(user_input=theme), return_tensors="pt").to(device=model.device)
|
32 |
+
with torch.no_grad():
|
33 |
+
outputs = model.generate(
|
34 |
+
**inputs,
|
35 |
+
max_new_tokens=256,
|
36 |
+
do_sample=True,
|
37 |
+
temperature=0.8,
|
38 |
+
eos_token_id=tokenizer.eos_token_id
|
39 |
+
)
|
40 |
+
print(tokenizer.decode(outputs[0],skip_special_tokens=True))
|
41 |
+
```
|
42 |
+
|
43 |
+
## 備考
|
44 |
+
Discordサーバー「ローカルLLMに向き合う会」とメタデータラボ株式会社が共同開催された「[LOCAL AI HACKATHON #000](https://prtimes.jp/main/html/rd/p/000000007.000056944.html)」にて作成した成果物になります。
|