YMIMURA commited on
Commit
e0bc29d
·
verified ·
1 Parent(s): 5d69756

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -2
README.md CHANGED
@@ -6,11 +6,69 @@ tags:
6
  - unsloth
7
  - llama
8
  - trl
9
- license: apache-2.0
10
  language:
11
  - en
12
  ---
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # Uploaded model
15
 
16
  - **Developed by:** YMIMURA
@@ -19,4 +77,4 @@ language:
19
 
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)
 
6
  - unsloth
7
  - llama
8
  - trl
9
+ license: cc-by-nc-sa-4.0
10
  language:
11
  - en
12
  ---
13
 
14
+ # 使用データセット
15
+ (1)
16
+ https://liat-aip.sakura.ne.jp/wp/llmのための日本語インストラクションデータ作成/llmのための日本語インストラクションデータ-公開/
17
+ 関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. ichikara-instruction: LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024)
18
+
19
+ # Sample Use
20
+
21
+ '''Python'''
22
+ from unsloth import FastLanguageModel
23
+ import torch
24
+ import json
25
+ model_name = "YMIMURA/llm-jp-3-13b-finetune-3"
26
+ max_seq_length = 2048
27
+ dtype = None
28
+ load_in_4bit = True
29
+
30
+ model, tokenizer = FastLanguageModel.from_pretrained(
31
+ model_name = model_name,
32
+ max_seq_length = max_seq_length,
33
+ dtype = dtype,
34
+ load_in_4bit = load_in_4bit,
35
+ token = "YOUR_TOKEN",
36
+ )
37
+ FastLanguageModel.for_inference(model)
38
+
39
+ datasets = []
40
+ with open("./elyza-tasks-100-TV_0.jsonl", "r") as f:
41
+ item = ""
42
+ for line in f:
43
+ line = line.strip()
44
+ item += line
45
+ if item.endswith("}"):
46
+ datasets.append(json.loads(item))
47
+ item = ""
48
+
49
+ from tqdm import tqdm
50
+
51
+ # 推論
52
+ results = []
53
+ for dt in tqdm(datasets):
54
+ input = dt["input"]
55
+
56
+ prompt = f"""### 指示\n{input}\n### 回答\n"""
57
+
58
+ inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
59
+
60
+ outputs = model.generate(**inputs, max_new_tokens = 512, use_cache = True, do_sample=False, repetition_penalty=1.2)
61
+ prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
62
+
63
+ results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
64
+
65
+ with open(f"/content/{model_name}_output.jsonl", 'w', encoding='utf-8') as f:
66
+ for result in results:
67
+ json.dump(result, f, ensure_ascii=False)
68
+ f.write('\n')
69
+
70
+ '''''''ここまで''''''
71
+
72
  # Uploaded model
73
 
74
  - **Developed by:** YMIMURA
 
77
 
78
  This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
79
 
80
+ [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)