KKFurudate
commited on
Commit
•
7f989f4
1
Parent(s):
9110b79
Update README.md
Browse files
README.md
CHANGED
@@ -28,7 +28,6 @@ This llama model was trained 2x faster with [Unsloth](https://github.com/unsloth
|
|
28 |
# Instruction Tuning
|
29 |
|
30 |
以下の日本語データセットで微調整を行いました:
|
31 |
-
|
32 |
| Language | Dataset | Description |
|
33 |
|:---|:---|:---|
|
34 |
| Japanese | [ichikara-instruction-003-001-1.json](https://liat-aip.sakura.ne.jp/wp/llm%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%A9%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%87%E3%83%BC%E3%82%BF-%E5%85%AC%E9%96%8B/) | 手動構築の日本語指示データセット |
|
@@ -59,14 +58,15 @@ import re
|
|
59 |
HF_TOKEN = "YOUR-HF-TOKEN"
|
60 |
```
|
61 |
|
62 |
-
|
63 |
```python
|
|
|
64 |
model_id = "llm-jp/llm-jp-3-13b"
|
65 |
adapter_id = "KKFurudate/llm-jp-3-13b-v6_lora"
|
66 |
```
|
67 |
|
68 |
```python
|
69 |
-
# unslothのFastLanguageModel
|
70 |
dtype = None
|
71 |
load_in_4bit = True
|
72 |
|
@@ -78,8 +78,9 @@ model, tokenizer = FastLanguageModel.from_pretrained(
|
|
78 |
)
|
79 |
```
|
80 |
|
81 |
-
|
82 |
```python
|
|
|
83 |
model = PeftModel.from_pretrained(model, adapter_id, token = HF_TOKEN)
|
84 |
```
|
85 |
|
@@ -95,8 +96,9 @@ with open("./YOUR-DATA.jsonl", "r") as f:
|
|
95 |
item = ""
|
96 |
```
|
97 |
|
98 |
-
|
99 |
```python
|
|
|
100 |
FastLanguageModel.for_inference(model)
|
101 |
|
102 |
results = []
|
@@ -113,8 +115,8 @@ for dt in tqdm(datasets):
|
|
113 |
results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
|
114 |
```
|
115 |
|
116 |
-
結果をjsonlで保存。
|
117 |
```python
|
|
|
118 |
json_file_id = re.sub(".*/", "", adapter_id)
|
119 |
with open(f"{outdir}/{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
|
120 |
for result in results:
|
|
|
28 |
# Instruction Tuning
|
29 |
|
30 |
以下の日本語データセットで微調整を行いました:
|
|
|
31 |
| Language | Dataset | Description |
|
32 |
|:---|:---|:---|
|
33 |
| Japanese | [ichikara-instruction-003-001-1.json](https://liat-aip.sakura.ne.jp/wp/llm%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%A9%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%87%E3%83%BC%E3%82%BF-%E5%85%AC%E9%96%8B/) | 手動構築の日本語指示データセット |
|
|
|
58 |
HF_TOKEN = "YOUR-HF-TOKEN"
|
59 |
```
|
60 |
|
61 |
+
|
62 |
```python
|
63 |
+
# ベースのモデルと学習済みLoRAのアダプタ(Hugging FaceのIDを指定)。
|
64 |
model_id = "llm-jp/llm-jp-3-13b"
|
65 |
adapter_id = "KKFurudate/llm-jp-3-13b-v6_lora"
|
66 |
```
|
67 |
|
68 |
```python
|
69 |
+
# unslothのFastLanguageModelでベースのモデルをロード。
|
70 |
dtype = None
|
71 |
load_in_4bit = True
|
72 |
|
|
|
78 |
)
|
79 |
```
|
80 |
|
81 |
+
|
82 |
```python
|
83 |
+
# ベースのモデルに学習済みLoRAのアダプタを統合。
|
84 |
model = PeftModel.from_pretrained(model, adapter_id, token = HF_TOKEN)
|
85 |
```
|
86 |
|
|
|
96 |
item = ""
|
97 |
```
|
98 |
|
99 |
+
|
100 |
```python
|
101 |
+
# モデルを用いてタスクの推論。
|
102 |
FastLanguageModel.for_inference(model)
|
103 |
|
104 |
results = []
|
|
|
115 |
results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
|
116 |
```
|
117 |
|
|
|
118 |
```python
|
119 |
+
# 結果をjsonlで保存。
|
120 |
json_file_id = re.sub(".*/", "", adapter_id)
|
121 |
with open(f"{outdir}/{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
|
122 |
for result in results:
|