umizkimt commited on
Commit
5e9d270
·
verified ·
1 Parent(s): 7143dd2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +115 -28
README.md CHANGED
@@ -21,31 +21,118 @@ This llama model was trained 2x faster with [Unsloth](https://github.com/unsloth
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
23
 
24
- # llm-jp-3-13b-it-lora
25
-
26
- # Required Libraries and Their Versions
27
-
28
- # Usage
29
-
30
- # Model Details
31
-
32
- # Datasets
33
-
34
- # Pre-training
35
-
36
- # Instruction tuning
37
-
38
- The models have been fine-tuned on the following datasets.
39
-
40
- |Language|Dataset|description|
41
- |----|----|----|
42
- |Japanese|ichikara-instruction-003-001-1.json|A manually constructed instruction dataset|
43
-
44
- # Send Questions to
45
-
46
- mitsuhiro.umizaki(at)gmail.com
47
-
48
- # License
49
-
50
- Apache License, Version 2.0
51
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
23
 
24
+ # umizkimt/llm-jp-3-13b-it_lora - Japanese Instruction-Tuned LLM
25
+
26
+ ## Overview
27
+ - Base Model: llm-jp/llm-jp-3-13b
28
+ - Purpose: Instruction-tuned model created for the final project of the LLM2024 course, designed for Japanese language tasks
29
+ - Key Features:
30
+ - Improved Japanese instruction understanding
31
+ - Preliminary enhancement of Japanese language response generation
32
+ - 13B parameter model with instruction tuning
33
+
34
+ ## Model Details
35
+ - Base Model: llm-jp/llm-jp-3-13b
36
+ - Fine-tuning Method: Unsloth LoRA (Low-Rank Adaptation)
37
+ - Training Dataset: ichikara-instruction-003-001-1.json (A manually constructed instruction dataset)
38
+ - Model Parameters: 13 billion
39
+ - Training Environment:
40
+ - Platform: Google Colaboratory
41
+ - Hardware: T4 GPU
42
+ - Training Duration: 46 minutes
43
+
44
+ ## Performance
45
+ - Omnicampus score: 3.02 (2024-11-29 19:20:27 JST)
46
+
47
+ ## How to Output the Submitted .jsonl File
48
+ ```python
49
+ # 必要なライブラリをインストール
50
+ %%capture
51
+ !pip install unsloth
52
+ !pip uninstall unsloth -y && pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
53
+ !pip install -U torch
54
+ !pip install -U peft
55
+ # .jsonlファイル出力時のライブラリバージョン
56
+ # unsloth: 2024.11.10
57
+ # peft: 0.13.2
58
+ # torch: 2.5.1+cu121
59
+
60
+ # 必要なライブラリを読み込み
61
+ from unsloth import FastLanguageModel
62
+ from peft import PeftModel
63
+ import torch
64
+ import json
65
+ from tqdm import tqdm
66
+ import re
67
+
68
+ # ベースとなるモデルと学習したLoRAのアダプタ(Hugging FaceのIDを指定)。
69
+ model_id = "llm-jp/llm-jp-3-13b"
70
+ adapter_id = "umizkimt/llm-jp-3-13b-it_lora"
71
+
72
+ # Hugging Face Token を指定。
73
+ HF_TOKEN = "<your-hugging-face-token>"
74
+
75
+ # unslothのFastLanguageModelで元のモデルをロード。
76
+ dtype = None # Noneにしておけば自動で設定
77
+ load_in_4bit = True # 今回は13Bモデルを扱うためTrue
78
+
79
+ model, tokenizer = FastLanguageModel.from_pretrained(
80
+ model_name=model_id,
81
+ dtype=dtype,
82
+ load_in_4bit=load_in_4bit,
83
+ trust_remote_code=True,
84
+ )
85
+
86
+ # 元のモデルにLoRAのアダプタを統合。
87
+ model = PeftModel.from_pretrained(model, adapter_id, token = HF_TOKEN)
88
+
89
+ # タスクとなるデータの読み込み。
90
+ # 事前にデータをアップロードしてください。
91
+ datasets = []
92
+ with open("./elyza-tasks-100-TV_0.jsonl", "r") as f:
93
+ item = ""
94
+ for line in f:
95
+ line = line.strip()
96
+ item += line
97
+ if item.endswith("}"):
98
+ datasets.append(json.loads(item))
99
+ item = ""
100
+
101
+ # モデルを用いてタスクの推論。
102
+
103
+ # 推論するためにモデルのモードを変更
104
+ FastLanguageModel.for_inference(model)
105
+
106
+ results = []
107
+ for dt in tqdm(datasets):
108
+ input = dt["input"]
109
+
110
+ prompt = f"""### 指示\n{input}\n### 回答\n"""
111
+
112
+ inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
113
+
114
+ outputs = model.generate(**inputs, max_new_tokens = 512, use_cache = True, do_sample=False, repetition_penalty=1.2)
115
+ prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
116
+
117
+ results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
118
+
119
+ # 結果をjsonlで保存。
120
+
121
+ # ここではadapter_idを元にファイル名を決定しているが、ファイル名は任意で問題なし。
122
+ json_file_id = re.sub(".*/", "", adapter_id)
123
+ with open(f"/content/{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
124
+ for result in results:
125
+ json.dump(result, f, ensure_ascii=False)
126
+ f.write('\n')
127
+ ```
128
+
129
+ ## Limitaitons
130
+ This model is in early development stages. Outputs may not consistently align with human intent and require careful validation. Potential for generating inappropriate or incorrect responses exists. Recommended for experimental use with human oversight.
131
+
132
+ ## License
133
+ TBD
134
+
135
+ This fine-tuned model is released under the CC BY-NC-SA 4.0 license, as it was trained on a dataset covered by the same license. The pre-trained model used as a starting point for fine-tuning is distributed under the Apache License 2.0.
136
+
137
+ ## Model Card Authors
138
+ Mitsuhiro Umizaki