Holy-fox commited on
Commit
718c60d
·
verified ·
1 Parent(s): acc2d33

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +200 -163
README.md CHANGED
@@ -1,199 +1,236 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
 
9
 
 
10
 
 
 
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
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
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
-
70
- ## How to Get Started with the Model
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
-
90
- [More Information Needed]
91
-
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
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
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
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
 
 
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
 
 
158
 
159
- ### Compute Infrastructure
 
 
 
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
 
 
 
164
 
165
- [More Information Needed]
 
 
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
 
177
- [More Information Needed]
 
 
 
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
 
 
 
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
 
 
 
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
 
 
 
 
 
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
 
 
 
 
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
 
198
 
199
- [More Information Needed]
 
 
 
 
 
 
 
1
  ---
2
  library_name: transformers
3
+ license: apache-2.0
4
+ datasets:
5
+ - TeamDelta/bare-ja-v0.1
6
+ language:
7
+ - ja
8
+ base_model:
9
+ - llm-jp/llm-jp-3-13b
10
+ pipeline_tag: text-generation
11
  ---
12
 
13
+ # ArrowIdeative-13b-NeoBase-ZERO-llm-jp
14
 
15
+ ## 概要
16
+ **ArrowIdeative-13b-NeoBase-ZERO-llm-jp** は、ベースモデルから **GRPO(RL)だけ**で事後学習を行うことを主軸に設計された、日本語向けLLMです。狙いとしては、典型的な「強い指示追従(Instruct)」に寄せ切らず、**ベースモデル寄りの“出力の自由度”**を残しつつ、**チャット運用に最低限必要な形式順守**と、**回答品質の底上げ**を同時に実現することです。
17
 
18
+ 位置づけを一言でまとめると:
19
 
20
+ - **「ある程度プロンプトエンジニアリングが効くベースモデル」**
21
+ - ただし **完全なInstructモデルではない**(過剰な同調・過剰な定型化を狙っていない)
22
 
23
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
+ ## モデルの要点
26
+ - **学習方式**:ベースモデルから **GRPOのみ**で直接作成(SFTを主軸にしない方針)
27
+ - **目的**:
28
+ 1. **チャットテンプレート順守**(例:終端トークンなど、形式崩れの抑制)
29
+ 2. **回答の品質向上**(報酬モデルによるスカラー報酬の導入)
30
+ - **特性**:ベースモデルに近い性格を維持しやすい設計(=指示追従の“均質化”を抑える意図)
31
 
32
+ ---
33
+ ## 推論コード
34
+
35
+ ```python
36
+ import torch
37
+ from copy import deepcopy
38
+ from transformers import AutoTokenizer, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList
39
+
40
+ # ===== モデル =====
41
+ model_path = "DataPilot/ArrowIdeative-13b-NeoBase-ZERO-llm-jp-v0.2"
42
+
43
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
44
+ model = AutoModelForCausalLM.from_pretrained(
45
+ model_path,
46
+ device_map="auto",
47
+ torch_dtype=torch.bfloat16,
48
+ )
49
+ model.eval()
50
+
51
+ system_prompt = """あなたは有能なアシスタントです。日本語で丁寧に答えてください。"""
52
+ prompt = """CPUとGPUの違いについて教えてください。"""
53
+
54
+ # (元コードのChatML形式を維持)
55
+ text = f"""<|im_start|>system
56
+ {system_prompt}<|im_end|>
57
+ <|im_start|>user
58
+ {prompt}<|im_end|>
59
+ <|im_start|>assistant
60
+ """
61
+
62
+ inputs = tokenizer(text, add_special_tokens=False, return_tensors="pt", return_token_type_ids=False).to(model.device)
63
+ prompt_len = inputs["input_ids"].shape[1]
64
+
65
+ # "<|im_end|>" のトークン列(1トークンとは限らないので列で扱う)
66
+ stop_ids = tokenizer.encode("<|im_end|>", add_special_tokens=False)
67
+ stop_ids = torch.tensor(stop_ids, device=model.device, dtype=inputs["input_ids"].dtype)
68
+
69
+ class StopOnImEnd(StoppingCriteria):
70
+ def __init__(self, stop_ids_tensor: torch.Tensor):
71
+ super().__init__()
72
+ self.stop_ids = stop_ids_tensor
73
+
74
+ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
75
+ k = int(self.stop_ids.numel())
76
+ if k == 0 or input_ids.shape[1] < k:
77
+ return False
78
+ return torch.equal(input_ids[0, -k:], self.stop_ids)
79
+
80
+ stopping_criteria = StoppingCriteriaList([StopOnImEnd(stop_ids)])
81
+
82
+ # 既定EOSで止まらないようにする(= "<|im_end|>" のみで停止させる)
83
+ gen_config = deepcopy(model.generation_config)
84
+ gen_config.eos_token_id = None
85
+ gen_config.pad_token_id = tokenizer.pad_token_id if tokenizer.pad_token_id is not None else model.config.eos_token_id
86
+
87
+ with torch.inference_mode():
88
+ output = model.generate(
89
+ **inputs,
90
+ generation_config=gen_config,
91
+ stopping_criteria=stopping_criteria,
92
+ max_new_tokens=1024,
93
+ do_sample=True,
94
+ top_p=0.95,
95
+ temperature=0.5,
96
+ repetition_penalty=1.05,
97
+ )
98
+
99
+ generated = tokenizer.decode(output[0, prompt_len:], skip_special_tokens=False)
100
+ print(generated.split("<|im_end|>", 1)[0])
101
+
102
+ ```
103
+ ---
104
 
105
+ ## ベースモデル
106
+ - Base: **llm-jp-3-13b**
107
+ https://huggingface.co/llm-jp/llm-jp-3-13b
108
 
109
+ ---
 
 
 
 
110
 
111
+ ## 使用データ(概要)
112
+ - Dataset: **TeamDelta/bare-ja-v0.1** の **質問(プロンプト)部分のみ**を一部利用
113
+ https://huggingface.co/datasets/TeamDelta/bare-ja-v0.1
114
 
115
+ このデータは、以下の合成フローにより作成されたものです(要約):
116
 
117
+ 1. **ベースモデル(Sarashina2-70b)**で質問/回答のたたき台を生成
118
+ 2. **Microsoft Phi-4-mini**で品質キュレーション(選別・整形)
119
+ 3. **Multilingual E5**で多様性フィルタリング(近似質問の除去、重複削減)
120
 
121
+ - 参照:Sarashina2-70b
122
+ https://www.sbintuitions.co.jp/blog/entry/2024/08/21/144254
123
+ - BARE用プロンプト:
124
+ https://github.com/foxn2000/sdg/blob/main/prompts/bare.txt
125
 
126
+ ---
127
 
128
+ ## 学習構成
129
+ ### 学習・推論フレームワーク
130
+ - 学習:**Unsloth**
131
+ - 報酬推論:**SGLang**
132
 
133
+ ### 使用デバイス
134
+ - **NVIDIA RTX 5090 (32GB)**:主学習
135
+ - **NVIDIA RTX 4060 Ti (16GB)**:報酬モデル推論
136
 
137
+ ### 報酬モデル
138
+ - **cyberagent/ca-reward-3b-ja**
139
+ https://huggingface.co/cyberagent/ca-reward-3b-ja
140
 
141
+ ---
142
 
143
+ ## 報酬設計(概要)
144
+ 報酬は以下の5つの報酬関数で構成され、多角的に学習を誘導します:
145
+
146
+ ### 1. **チャットテンプレートの順守**
147
+ - 終端トークン(`<|im_end|>`)の適切な出力とフォーマット準拠を評価
148
+ - **準拠時**: +1.0 × 長さファ���ター(短すぎる回答を抑制)
149
+ - **非準拠時**: -5.0(強いペナルティ)
150
+ - **極端に短い回答**: -5.0(15文字未満でハード拒否)
151
+
152
+ ### 2. **反復ペナルティ**
153
+ - n-gram(デフォルト6文字)の反復率でループ出力を検出
154
+ - ペナルティ: -0.5 × 反復率(最大 -2.0)
155
+ - RM-hack(冗長な繰り返しで高スコア獲得)を防止
156
+
157
+ ### 3. **オーバーロング抑制**
158
+ - max_completion_length近傍(85%以降)で段階的にペナルティ
159
+ - ソフトペナルティ: -0.8 × (進行率)^2.0(DAPO風)
160
+ - ハードペナルティ: -1.5(100%以上で切断時)
161
+ - 「最大長まで埋める」ドリフトを防止
162
+
163
+ ### 4. **グループ内多様性**
164
+ - 同一プロンプトに対する複数生成間の重複・類似を検出
165
+ - **完全重複**: -0.3(2個目以降)
166
+ - **高類似(Jaccard≥0.85)**: -0.2 × 類似度
167
+ - エントロピー崩壊(mode collapse)対策
168
+
169
+ ### 5. **回答品質(報酬モデル)**
170
+ - テンプレート準拠の場合のみ評価(ゲート制御)
171
+ - 外部RM(cyberagent/ca-reward-3b-ja)のスカラーを利用
172
+ - スケール: 1.0 × RMスコア、クリップ範囲: ±10.0
173
+ - **正値の場合のみ**長さファクター適用(短い回答への報酬を抑制)
174
+ - RM失敗時は`None`(マスク)として無視され学習に影響しない
175
+
176
+ ### 報酬の合成
177
+ - TRL GRPOが全報酬関数の出力を合算(オプションで重み付け可能)
178
+ - グループ内相対的優位性(advantage)を計算してポリシー勾配を算出
179
+ - 適応的KL制御(beta調整)で参照モデルからの乖離を制御
180
 
181
+ ---
182
 
183
+ ## 使い方(推奨)
184
+ ### 想定ユースケース
185
+ - 0→1のアイデア出し、探索的思考、下書き生成
186
+ - 指示を強く固定しすぎない対話(プロンプト設計で誘導する用途)
187
+ - ベースモデルの“面白さ”や多様性を残しつつ、最低限チャット運用したい場面
188
 
189
+ ### 注意点
190
+ - **強い安全アラインメントや厳密な指示追従**を最優先したモデルではありません
191
+ - プロンプト設計次第で出力が大きく振れます(=長所でも短所でもある)
192
+ - チャットテンプレートを使う場合、**テンプレート仕様に合わせた入出力**を推奨します
193
 
194
+ ---
195
 
196
+ ## 生成品質・挙動の指針
197
+ - **ベース寄り**:過度に無難な“合意的テンプレ回答”へ収束させることを目的にしていません
198
+ - **プロンプト耐性**:命令の書き方で結果が変わりやすい設計(指示の粒度が重要)
199
+ - **出力の個性**:SFT偏重で起きやすい均質化を避け、探索性を残す狙い
200
 
201
+ ---
202
 
203
+ ## 既知の制限
204
+ - 形式順守は改善しても、**厳密な指示追従**や**安全性の自動担保**を保証しません
205
+ - 報酬モデルのバイアス(価値観・スタイル)を受けます
206
+ - 一般的なInstructモデルと同じ評価軸で単純比較すると、用途によっては不利になる場合があります
207
 
208
+ ---
209
 
210
+ ## ライセンス
211
+ - ベースモデルおよび関連データセットのライセンスに従います。
212
+ 具体的には以下を参照してください:
213
+ - llm-jp-3-13b: https://huggingface.co/llm-jp/llm-jp-3-13b
214
+ - TeamDelta/bare-ja-v0.1: https://huggingface.co/datasets/TeamDelta/bare-ja-v0.1
215
+ - ca-reward-3b-ja: https://huggingface.co/cyberagent/ca-reward-3b-ja
216
 
217
+ ---
218
 
219
+ ## 謝辞
220
+ - llm-jp プロジェクト
221
+ - TeamDelta / bare-ja-v0.1
222
+ - サイバーエージェント(ca-reward-3b-ja)
223
+ - Unsloth / SGLang および関連OSS
224
 
225
+ ---
226
 
227
+ ## 引用(必要に応じて)
228
+ このリポジトリやモデルカードを引用する場合は、以下をベースに調整してください:
229
 
230
+ ```bibtex
231
+ @misc{arrowideative_13b_neobase_zero_llm_jp,
232
+ title = {ArrowIdeative-13b-NeoBase-ZERO-llm-jp},
233
+ author = {holy-fox},
234
+ year = {2026},
235
+ }
236
+ ```