Transformers
Safetensors
Japanese
PonsukeUrayama commited on
Commit
3f70d51
·
verified ·
1 Parent(s): 71103bf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +146 -33
README.md CHANGED
@@ -1,6 +1,15 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
  # Model Card for Model ID
@@ -11,37 +20,41 @@ tags: []
11
 
12
  ## Model Details
13
 
 
 
 
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
  - **Funded by [optional]:** [More Information Needed]
22
  - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
  ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
 
31
 
32
- - **Repository:** [More Information Needed]
33
  - **Paper [optional]:** [More Information Needed]
34
  - **Demo [optional]:** [More Information Needed]
35
 
36
  ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
 
40
  ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
  ### Downstream Use [optional]
47
 
@@ -51,19 +64,20 @@ This is the model card of a 🤗 transformers model that has been pushed on the
51
 
52
  ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
55
 
56
- [More Information Needed]
57
 
58
  ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
61
 
62
- [More Information Needed]
63
 
64
  ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
  Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
@@ -71,19 +85,117 @@ Users (both direct and downstream) should be made aware of the risks, biases and
71
 
72
  Use the code below to get started with the model.
73
 
74
- [More Information Needed]
75
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  ## Training Details
77
 
 
 
 
 
78
  ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
83
 
84
  ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
 
 
 
 
 
87
 
88
  #### Preprocessing [optional]
89
 
@@ -92,35 +204,36 @@ Use the code below to get started with the model.
92
 
93
  #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
 
97
  #### Speeds, Sizes, Times [optional]
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
 
100
 
101
- [More Information Needed]
102
 
103
  ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
 
107
  ### Testing Data, Factors & Metrics
108
 
 
 
109
  #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
112
 
113
  [More Information Needed]
114
 
115
  #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
 
119
  [More Information Needed]
120
 
121
  #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
  [More Information Needed]
126
 
@@ -134,13 +247,14 @@ Use the code below to get started with the model.
134
 
135
  ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
138
 
139
  [More Information Needed]
140
 
141
  ## Environmental Impact
 
 
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
  Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
 
@@ -166,11 +280,10 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
166
 
167
  #### Software
168
 
169
- [More Information Needed]
170
 
171
  ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
  **BibTeX:**
176
 
 
1
  ---
2
  library_name: transformers
3
+ license: cc
4
+ datasets:
5
+ - kinokokoro/ichikara-instruction-003
6
+ language:
7
+ - ja
8
+ metrics:
9
+ - accuracy
10
+ base_model:
11
+ - llm-jp/llm-jp-3-3.7b
12
+ - llm-jp/llm-jp-3-13b
13
  ---
14
 
15
  # Model Card for Model ID
 
20
 
21
  ## Model Details
22
 
23
+ Final competition report for weblab.t.u-tokyo.ac.jp/lecture/course-list/large-language-model/
24
+ Using finetuning and some other methods to have better result for elyza-tasks-100-TV_0
25
+ With the optimization Technolkogy of Quantamize, PEFT.
26
+
27
  ### Model Description
28
 
29
+ https://drive.google.com/drive/folders/1TcEpKngy72fbxXcu4VxoVUbPfvg8Z1z0
30
 
31
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
32
 
33
+ - **Developed by:Yohei.KObayashi with modification by Hiroshi Hayashi
34
  - **Funded by [optional]:** [More Information Needed]
35
  - **Shared by [optional]:** [More Information Needed]
36
+ - **Model type: llm-jp/llm-jp
37
+ - **Language(s) (NLP): Japanese
38
+ - **License: CC-BY-NC-SA
39
+ - **Finetuned from model [optional]:Quantamize, PEFT
40
 
41
  ### Model Sources [optional]
42
 
43
+ llm-jp-3 1.8B, 3.7B, 13B
44
+
45
 
46
+ - **Repository:-- [More Information Needed]
47
  - **Paper [optional]:** [More Information Needed]
48
  - **Demo [optional]:** [More Information Needed]
49
 
50
  ## Uses
51
 
52
+ Learn and get experience to use fine tuning technology and learn how to inplement such fine tuning technologies
53
 
54
  ### Direct Use
55
 
56
+ No intension to be used with such case
57
 
 
58
 
59
  ### Downstream Use [optional]
60
 
 
64
 
65
  ### Out-of-Scope Use
66
 
67
+ This code is only for students and trainee fo AI implementation.
68
+ Not fully tested for the actual project use case
69
 
 
70
 
71
  ## Bias, Risks, and Limitations
72
 
73
+ This program and updated file is generated by the code by Yohei Kobayashi for training coase by Matsuo-lab @ Tokyo university.
74
+ https://weblab.t.u-tokyo.ac.jp/lecture/course-list/large-language-model/
75
+ Please contact Matsuo-Lab if you plan to use this code and any files related to this project.
76
 
 
77
 
78
  ### Recommendations
79
 
80
+ Any students who tries using LLM, this is very useful to understand and get started fromthe perspective of academic perpose
81
 
82
  Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
83
 
 
85
 
86
  Use the code below to get started with the model.
87
 
88
+ from transformers import (
89
+ AutoModelForCausalLM,
90
+ AutoTokenizer,
91
+ BitsAndBytesConfig,
92
+ )
93
+ from peft import PeftModel
94
+ import torch
95
+ from tqdm import tqdm
96
+ import json
97
+
98
+ HF_TOKEN = "Hugging Face Token"
99
+
100
+ model_id = "" # < Model folder path
101
+ adapter_id = "" # Hugging Face ID
102
+
103
+ # QLoRA config
104
+ bnb_config = BitsAndBytesConfig(
105
+ load_in_4bit=True,
106
+ bnb_4bit_quant_type="nf4",
107
+ bnb_4bit_compute_dtype=torch.bfloat16,
108
+ )
109
+
110
+ # Load model
111
+ model = AutoModelForCausalLM.from_pretrained(
112
+ model_id,
113
+ quantization_config=bnb_config,
114
+ device_map="auto",
115
+ token = HF_TOKEN
116
+ )
117
+
118
+ # Load tokenizer
119
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True, token = HF_TOKEN)
120
+
121
+ model = PeftModel.from_pretrained(model, adapter_id, token = HF_TOKEN)
122
+
123
+ datasets = []
124
+ with open("./elyza-tasks-100-TV_0.jsonl", "r") as f:
125
+ item = ""
126
+ for line in f:
127
+ line = line.strip()
128
+ item += line
129
+ if item.endswith("}"):
130
+ datasets.append(json.loads(item))
131
+ item = ""
132
+ results = []
133
+ for data in tqdm(datasets):
134
+
135
+ input = data["input"]
136
+ prompt = f"""### Direction
137
+ {input}
138
+ ### Answers
139
+ """
140
+
141
+ input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)
142
+ outputs = model.generate(**input_ids, max_new_tokens=512, do_sample=False, repetition_penalty=1.2,)
143
+ output = tokenizer.decode(outputs[0][input_ids.input_ids.size(1):], skip_special_tokens=True)
144
+
145
+ results.append({"task_id": data["task_id"], "input": input, "output": output})
146
+
147
+ results = []
148
+ for data in tqdm(datasets):
149
+
150
+ input = data["input"]
151
+
152
+ prompt = f"""### 指示
153
+ {input}
154
+ ### 回答
155
+ """
156
+
157
+ tokenized_input = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
158
+ attention_mask = torch.ones_like(tokenized_input)
159
+ with torch.no_grad():
160
+ outputs = model.generate(
161
+ tokenized_input,
162
+ attention_mask=attention_mask,
163
+ max_new_tokens=100,
164
+ do_sample=False,
165
+ repetition_penalty=1.2,
166
+ pad_token_id=tokenizer.eos_token_id
167
+ )[0]
168
+ output = tokenizer.decode(outputs[tokenized_input.size(1):], skip_special_tokens=True)
169
+
170
+ results.append({"task_id": data["task_id"], "input": input, "output": output})
171
+
172
+ import re
173
+ jsonl_id = re.sub(".*/", "", adapter_id)
174
+ with open(f"./{jsonl_id}-outputs.jsonl", 'w', encoding='utf-8') as f:
175
+ for result in results:
176
+ json.dump(result, f, ensure_ascii=False) # ensure_ascii=False for handling non-ASCII characters
177
+ f.write('\n')
178
+
179
+
180
  ## Training Details
181
 
182
+ Used "Ichikara Instruction"
183
+ ichikara-instruction-003-001-1.json
184
+
185
+
186
  ### Training Data
187
 
188
+ https://liat-aip.sakura.ne.jp/wp/llmのための日本語インストラクションデータ作成/llmのための日本語インストラクションデータ-公開/
189
 
 
190
 
191
  ### Training Procedure
192
 
193
+ PEFT
194
+ LoRA rank : 16
195
+ Scaling factor : lora_alpha 32
196
+ Dropout ratio : 0.05
197
+ No Bias
198
+
199
 
200
  #### Preprocessing [optional]
201
 
 
204
 
205
  #### Training Hyperparameters
206
 
207
+
208
 
209
  #### Speeds, Sizes, Times [optional]
210
 
211
+ 36:53
212
+ 864/864
213
+ Epoch 0/1
214
 
 
215
 
216
  ## Evaluation
217
 
218
+ elyza-tasks-100-TV_0.jsonl
219
 
220
  ### Testing Data, Factors & Metrics
221
 
222
+ elyza-tasks-100 with latest TV and TV show related information
223
+
224
  #### Testing Data
225
 
 
226
 
227
  [More Information Needed]
228
 
229
  #### Factors
230
 
 
231
 
232
  [More Information Needed]
233
 
234
  #### Metrics
235
 
236
+ accuracy with limiteation of model execution time
237
 
238
  [More Information Needed]
239
 
 
247
 
248
  ## Model Examination [optional]
249
 
250
+
251
 
252
  [More Information Needed]
253
 
254
  ## Environmental Impact
255
+ CPU memory : 48GB
256
+ GPU: L4 (24G)
257
 
 
258
 
259
  Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
260
 
 
280
 
281
  #### Software
282
 
283
+ Python 3.10.6
284
 
285
  ## Citation [optional]
286
 
 
287
 
288
  **BibTeX:**
289