Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: llm-jp/llm-jp-3-13b
|
3 |
+
library_name: peft
|
4 |
+
tags:
|
5 |
+
- text-generation-inference
|
6 |
+
- llama
|
7 |
+
- trl
|
8 |
+
license: apache-2.0
|
9 |
+
---
|
10 |
+
|
11 |
+
# Model Card for Model ID
|
12 |
+
|
13 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
## Model Details
|
18 |
+
|
19 |
+
### Model Description
|
20 |
+
|
21 |
+
<!-- Provide a longer summary of what this model is. -->
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
- **Developed by:** togepi55
|
26 |
+
- **Funded by [optional]:** llm-jp/llm-jp-3-13b
|
27 |
+
- **Shared by [optional]:** [More Information Needed]
|
28 |
+
- **Model type:** [More Information Needed]
|
29 |
+
- **Language(s) (NLP):** [More Information Needed]
|
30 |
+
- **License:** apache-2.0
|
31 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
32 |
+
|
33 |
+
### Model Sources [optional]
|
34 |
+
|
35 |
+
<!-- Provide the basic links for the model. -->
|
36 |
+
|
37 |
+
- **Repository:** [More Information Needed]
|
38 |
+
- **Paper [optional]:** [More Information Needed]
|
39 |
+
- **Demo [optional]:** [More Information Needed]
|
40 |
+
|
41 |
+
## Uses
|
42 |
+
|
43 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
44 |
+
|
45 |
+
### 注意
|
46 |
+
プロンプトは形式でのみ学習しています。
|
47 |
+
~~~
|
48 |
+
"<s>以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい
|
49 |
+
|
50 |
+
### 指示:
|
51 |
+
{instruction}
|
52 |
+
|
53 |
+
### 応答:"
|
54 |
+
~~~
|
55 |
+
|
56 |
+
### サンプルコード
|
57 |
+
|
58 |
+
~~~python
|
59 |
+
import torch
|
60 |
+
from transformers import (
|
61 |
+
AutoTokenizer,
|
62 |
+
AutoModelForCausalLM,
|
63 |
+
BitsAndBytesConfig,
|
64 |
+
)
|
65 |
+
from transformers import TextStreamer
|
66 |
+
|
67 |
+
|
68 |
+
BASE_MODEL = "togepi55/llm-jp-3-13b-it"
|
69 |
+
|
70 |
+
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
|
71 |
+
bnb_config = BitsAndBytesConfig(
|
72 |
+
load_in_4bit=True,
|
73 |
+
bnb_4bit_compute_dtype=torch.float16,
|
74 |
+
bnb_4bit_quant_type="nf4",
|
75 |
+
bnb_4bit_use_double_quant=False,
|
76 |
+
)
|
77 |
+
|
78 |
+
model = AutoModelForCausalLM.from_pretrained(
|
79 |
+
BASE_MODEL,
|
80 |
+
device_map="auto",
|
81 |
+
quantization_config=bnb_config,
|
82 |
+
#torch_dtype=torch.bfloat16,
|
83 |
+
torch_dtype="auto",
|
84 |
+
trust_remote_code=True,
|
85 |
+
)
|
86 |
+
|
87 |
+
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
88 |
+
|
89 |
+
|
90 |
+
instruction = "東京は日本の"
|
91 |
+
|
92 |
+
|
93 |
+
prompt = f"<s>以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい\n\n### 指示:\n{instruction}\n\n### 応答:\n"
|
94 |
+
print(prompt)
|
95 |
+
model_input = tokenizer(prompt, return_tensors="pt").to(model.device)
|
96 |
+
input_ids = model_input["input_ids"]
|
97 |
+
|
98 |
+
model.eval()
|
99 |
+
with torch.no_grad():
|
100 |
+
result = model.generate(
|
101 |
+
input_ids,
|
102 |
+
max_new_tokens=300,
|
103 |
+
attention_mask = model_input.attention_mask,
|
104 |
+
pad_token_id=tokenizer.pad_token_id,
|
105 |
+
eos_token_id=tokenizer.eos_token_id,
|
106 |
+
do_sample=False,
|
107 |
+
#num_return_sequences=3,
|
108 |
+
streamer=streamer,
|
109 |
+
repetition_penalty=1.02,
|
110 |
+
)
|
111 |
+
print("----"*20)
|
112 |
+
del input_ids
|
113 |
+
~~~
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
### Direct Use
|
120 |
+
|
121 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
122 |
+
|
123 |
+
[More Information Needed]
|
124 |
+
|
125 |
+
### Downstream Use [optional]
|
126 |
+
|
127 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
### Out-of-Scope Use
|
132 |
+
|
133 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
134 |
+
|
135 |
+
[More Information Needed]
|
136 |
+
|
137 |
+
## Bias, Risks, and Limitations
|
138 |
+
|
139 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
140 |
+
|
141 |
+
RLHF,DPOを実施していないため不適切な表現が出力される可能性があります。
|
142 |
+
|
143 |
+
## Training Details
|
144 |
+
|
145 |
+
### Training Data
|
146 |
+
|
147 |
+
指示チューニングデータとして下記のものを利用しました。
|
148 |
+
* ichikara-instruction-003-001-1.json
|
149 |
+
* ichikara-instruction-003-002-1.json
|
150 |
+
* elyza/ELYZA-tasks-100
|
151 |
+
|
152 |
+
### SFTの概要
|
153 |
+
* 4bit量子化
|
154 |
+
* LoRAによるSFT
|
155 |
+
* learning_rate = 2e-4
|
156 |
+
* optim="adamw_torch_fused"
|
157 |
+
* lr_scheduler_type="cosine"
|
158 |
+
* weight_decay=0.01
|
159 |
+
|
160 |
+
|