Update README.md
Browse files
README.md
CHANGED
@@ -9,6 +9,7 @@ tags:
|
|
9 |
license: apache-2.0
|
10 |
language:
|
11 |
- en
|
|
|
12 |
---
|
13 |
|
14 |
# Uploaded model
|
@@ -20,3 +21,88 @@ 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
license: apache-2.0
|
10 |
language:
|
11 |
- en
|
12 |
+
- ja
|
13 |
---
|
14 |
|
15 |
# Uploaded model
|
|
|
21 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
22 |
|
23 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
24 |
+
|
25 |
+
|
26 |
+
## 学習データ
|
27 |
+
|
28 |
+
使用したSupervised fien-tune用dataset:下記からランダムに20000データを抽出
|
29 |
+
DeL-TaiseiOzaki/Tengentoppa-sft-v1.0
|
30 |
+
🌾 ランダムに20000データを取り出して学習
|
31 |
+
|
32 |
+
SFTに用いた継続事前学習モデル
|
33 |
+
ikedachin/llm-jp-3-13b-october-news-e1-all-3-5
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
### 実行コード
|
38 |
+
|
39 |
+
```:Python
|
40 |
+
# import libraries
|
41 |
+
import re
|
42 |
+
import json
|
43 |
+
|
44 |
+
import torch
|
45 |
+
|
46 |
+
from peft import PeftModel
|
47 |
+
from tqdm import tqdm
|
48 |
+
from unsloth import FastLanguageModel
|
49 |
+
|
50 |
+
# define base model_id and peft model_id
|
51 |
+
model_id = "llm-jp/llm-jp-3-13b"
|
52 |
+
adapter_id = "ikedachin/llm-jp-3-13b-october-news-e1-all-3-5-sft-ozaki-30000"
|
53 |
+
|
54 |
+
dtype = None
|
55 |
+
load_in_4bit
|
56 |
+
|
57 |
+
# down load base model
|
58 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
59 |
+
model_name=model_id,
|
60 |
+
dtype=dtype,
|
61 |
+
load_in_4bit=load_in_4bit,
|
62 |
+
trust_remote_code=True,
|
63 |
+
)
|
64 |
+
|
65 |
+
# adapt peft model
|
66 |
+
model = PeftModel.from_pretrained(model, adapter_id, token = HF_TOKEN)
|
67 |
+
|
68 |
+
|
69 |
+
# prepare dataset elyza-tasks-100-TV_0.jsonl
|
70 |
+
datasets_elyza = []
|
71 |
+
|
72 |
+
with open('./elyza-tasks-100-TV_0.jsonl', 'r') as f:
|
73 |
+
item = ""
|
74 |
+
for line in f:
|
75 |
+
line = line.strip()
|
76 |
+
item += line
|
77 |
+
if item.endswith("}"):
|
78 |
+
datasets_elyza.append(json.loads(item))
|
79 |
+
item = ""
|
80 |
+
|
81 |
+
|
82 |
+
# change mode for inference
|
83 |
+
FastLanguageModel.for_inference(model)
|
84 |
+
|
85 |
+
# inferrence
|
86 |
+
results = []
|
87 |
+
|
88 |
+
for dt in tqdm(datasets):
|
89 |
+
input = dt["input"]
|
90 |
+
|
91 |
+
prompt = f"""### 指示\n{input}\n### 回答\n"""
|
92 |
+
|
93 |
+
inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
|
94 |
+
|
95 |
+
outputs = model.generate(**inputs, max_new_tokens = 512, use_cache = True, do_sample=False, repetition_penalty=1.2)
|
96 |
+
prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
|
97 |
+
|
98 |
+
results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
|
99 |
+
|
100 |
+
# create result file as jsonl type
|
101 |
+
json_file_id = re.sub(".*/", adapter_id)
|
102 |
+
with open(f"/content/{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
|
103 |
+
for result in results:
|
104 |
+
json.dump(result, f, ensure_ascii=False)
|
105 |
+
f.write('\n')
|
106 |
+
|
107 |
+
|
108 |
+
```
|