154teru commited on
Commit
e689430
·
verified ·
1 Parent(s): 5d7b593

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -11
README.md CHANGED
@@ -6,7 +6,6 @@ tags:
6
  - unsloth
7
  - llama
8
  - trl
9
- license: apache-2.0
10
  language:
11
  - ja
12
  ---
@@ -39,6 +38,10 @@ LLM-JP-3-13Bモデルを使用し、
39
  GoogleColaboratoryで推論を行うためのテンプレート。
40
  Unslothを使用。
41
 
 
 
 
 
42
  ## インストール
43
 
44
  ```bash
@@ -47,22 +50,30 @@ pip uninstall unsloth -y && pip install --upgrade --no-cache-dir "unsloth[colab-
47
  pip install -U torch
48
  pip install -U peft
49
  ```
50
- 必要なライブラリは適宜保存してください。
51
 
 
 
 
 
 
 
 
 
 
52
  ## 使用方法
53
 
54
- 1. Hugging Faceのトークンを設定します
55
  ```python
56
  HF_TOKEN = "your_token_here"
57
  ```
58
 
59
- 2. ベースモデルとLoRAアダプターのIDを指定します
60
  ```python
61
  model_id = "llm-jp/llm-jp-3-13b"
62
  adapter_id = "154teru/llm-jp-3-13b-it15a4_fullset_lora"
63
  ```
64
 
65
- 3. モデルとトークナイザーをロードします
66
  ```python
67
  model, tokenizer = FastLanguageModel.from_pretrained(
68
  model_name=model_id,
@@ -72,12 +83,12 @@ model, tokenizer = FastLanguageModel.from_pretrained(
72
  )
73
  ```
74
 
75
- 4. LoRAアダプターを統合します
76
  ```python
77
  model = PeftModel.from_pretrained(model, adapter_id, token=HF_TOKEN)
78
  ```
79
 
80
- 5. 入力データを準備します
81
  - JSONLフォーマットで、以下の構造を持つファイルを用意します:
82
  ```json
83
  {
@@ -86,7 +97,7 @@ model = PeftModel.from_pretrained(model, adapter_id, token=HF_TOKEN)
86
  }
87
  ```
88
 
89
- 6. 推論を実行します
90
  ```python
91
  FastLanguageModel.for_inference(model)
92
  results = []
@@ -96,7 +107,7 @@ for dt in tqdm(datasets):
96
  # 推論処理
97
  ```
98
 
99
- 7. 結果を保存します
100
  ```python
101
  json_file_id = re.sub(".*/", "", adapter_id)
102
  with open(f"{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
@@ -105,9 +116,9 @@ with open(f"{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
105
  f.write('\n')
106
  ```
107
 
108
- ## 出力フォーマット
109
 
110
- 結果は以下の形式のJSONLファイルとして保存されます:
111
  ```json
112
  {
113
  "task_id": "タスクID",
 
6
  - unsloth
7
  - llama
8
  - trl
 
9
  language:
10
  - ja
11
  ---
 
38
  GoogleColaboratoryで推論を行うためのテンプレート。
39
  Unslothを使用。
40
 
41
+ 開発方針はSFTを中心として、datasetを人間の目と感性で
42
+ 可能な限り一貫性を持たせた。
43
+ 同時にパラメータを調整し、サンプルコードからmax_seq_length = 2048に変更。
44
+
45
  ## インストール
46
 
47
  ```bash
 
50
  pip install -U torch
51
  pip install -U peft
52
  ```
 
53
 
54
+ 必要なライブラリは適宜保存してください。
55
+ ```bash
56
+ from unsloth import FastLanguageModel
57
+ from peft import PeftModel
58
+ import torch
59
+ import json
60
+ from tqdm import tqdm
61
+ import re
62
+ ```
63
  ## 使用方法
64
 
65
+ 1. Hugging Faceのトークンを設定
66
  ```python
67
  HF_TOKEN = "your_token_here"
68
  ```
69
 
70
+ 2. ベースモデルとLoRAアダプターのIDを指定
71
  ```python
72
  model_id = "llm-jp/llm-jp-3-13b"
73
  adapter_id = "154teru/llm-jp-3-13b-it15a4_fullset_lora"
74
  ```
75
 
76
+ 3. モデルとトークナイザーをロード
77
  ```python
78
  model, tokenizer = FastLanguageModel.from_pretrained(
79
  model_name=model_id,
 
83
  )
84
  ```
85
 
86
+ 4. LoRAアダプターを統合
87
  ```python
88
  model = PeftModel.from_pretrained(model, adapter_id, token=HF_TOKEN)
89
  ```
90
 
91
+ 5. 入力データを準備
92
  - JSONLフォーマットで、以下の構造を持つファイルを用意します:
93
  ```json
94
  {
 
97
  }
98
  ```
99
 
100
+ 6. 推論を実行
101
  ```python
102
  FastLanguageModel.for_inference(model)
103
  results = []
 
107
  # 推論処理
108
  ```
109
 
110
+ 7. 結果を保存
111
  ```python
112
  json_file_id = re.sub(".*/", "", adapter_id)
113
  with open(f"{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
 
116
  f.write('\n')
117
  ```
118
 
119
+ ## 出力
120
 
121
+ JSONLファイルとして保存
122
  ```json
123
  {
124
  "task_id": "タスクID",