ayousanz commited on
Commit
efbca58
·
verified ·
1 Parent(s): 9c363ee

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +205 -196
README.md CHANGED
@@ -2,206 +2,215 @@
2
  base_model: google/gemma-2-2b-it
3
  library_name: peft
4
  pipeline_tag: text-generation
 
 
 
5
  tags:
6
- - base_model:adapter:google/gemma-2-2b-it
7
  - lora
8
  - transformers
 
 
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:** [More Information Needed]
26
- - **Funded by [optional]:** [More Information Needed]
27
- - **Shared by [optional]:** [More Information Needed]
28
- - **Model type:** [More Information Needed]
29
- - **Language(s) (NLP):** [More Information Needed]
30
- - **License:** [More Information Needed]
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
- ### Direct Use
46
-
47
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
48
-
49
- [More Information Needed]
50
-
51
- ### Downstream Use [optional]
52
-
53
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
54
-
55
- [More Information Needed]
56
-
57
- ### Out-of-Scope Use
58
-
59
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
60
-
61
- [More Information Needed]
62
-
63
- ## Bias, Risks, and Limitations
64
-
65
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
66
-
67
- [More Information Needed]
68
-
69
- ### Recommendations
70
-
71
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
72
-
73
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
74
-
75
- ## How to Get Started with the Model
76
-
77
- Use the code below to get started with the model.
78
-
79
- [More Information Needed]
80
-
81
- ## Training Details
82
-
83
- ### Training Data
84
-
85
- <!-- 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. -->
86
-
87
- [More Information Needed]
88
-
89
- ### Training Procedure
90
-
91
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
92
-
93
- #### Preprocessing [optional]
94
-
95
- [More Information Needed]
96
-
97
-
98
- #### Training Hyperparameters
99
-
100
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
101
-
102
- #### Speeds, Sizes, Times [optional]
103
-
104
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
105
-
106
- [More Information Needed]
107
-
108
- ## Evaluation
109
-
110
- <!-- This section describes the evaluation protocols and provides the results. -->
111
-
112
- ### Testing Data, Factors & Metrics
113
-
114
- #### Testing Data
115
-
116
- <!-- This should link to a Dataset Card if possible. -->
117
-
118
- [More Information Needed]
119
-
120
- #### Factors
121
-
122
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
123
-
124
- [More Information Needed]
125
-
126
- #### Metrics
127
-
128
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
129
-
130
- [More Information Needed]
131
-
132
- ### Results
133
-
134
- [More Information Needed]
135
-
136
- #### Summary
137
-
138
-
139
-
140
- ## Model Examination [optional]
141
-
142
- <!-- Relevant interpretability work for the model goes here -->
143
-
144
- [More Information Needed]
145
-
146
- ## Environmental Impact
147
-
148
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
149
-
150
- 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).
151
-
152
- - **Hardware Type:** [More Information Needed]
153
- - **Hours used:** [More Information Needed]
154
- - **Cloud Provider:** [More Information Needed]
155
- - **Compute Region:** [More Information Needed]
156
- - **Carbon Emitted:** [More Information Needed]
157
-
158
- ## Technical Specifications [optional]
159
-
160
- ### Model Architecture and Objective
161
-
162
- [More Information Needed]
163
-
164
- ### Compute Infrastructure
165
-
166
- [More Information Needed]
167
-
168
- #### Hardware
169
-
170
- [More Information Needed]
171
-
172
- #### Software
173
-
174
- [More Information Needed]
175
-
176
- ## Citation [optional]
177
-
178
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
179
-
180
- **BibTeX:**
181
-
182
- [More Information Needed]
183
-
184
- **APA:**
185
-
186
- [More Information Needed]
187
-
188
- ## Glossary [optional]
189
-
190
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
191
-
192
- [More Information Needed]
193
-
194
- ## More Information [optional]
195
-
196
- [More Information Needed]
197
-
198
- ## Model Card Authors [optional]
199
-
200
- [More Information Needed]
201
-
202
- ## Model Card Contact
203
-
204
- [More Information Needed]
205
- ### Framework versions
206
 
207
- - PEFT 0.17.1
 
2
  base_model: google/gemma-2-2b-it
3
  library_name: peft
4
  pipeline_tag: text-generation
5
+ language:
6
+ - ja
7
+ - en
8
  tags:
 
9
  - lora
10
  - transformers
11
+ - game-strategy
12
+ license: apache-2.0
13
  ---
14
 
15
+ # Gemma-2-2B-IT ゲーム戦略ファインチューニングモデル
16
+
17
+ ## モデル概要
18
+
19
+ このモデルは、Googleの[Gemma-2-2B-IT](https://huggingface.co/google/gemma-2-2b-it)をベースに、22個のゲーム戦略知識をLoRA(Low-Rank Adaptation)でファインチューニングしたものです。
20
+
21
+ **学習内容:**
22
+ - 5つの基本戦略タイプ(Offensive, Defensive, Adaptive, Disruptive, Endurance)
23
+ - 7つの攻撃側決定基準(Cumulative Probability Focus, Recent Pattern Focus, Speed Focus, Return Focus, Feint Focus, Distribution Focus, Energy Efficiency Focus)
24
+ - 7つの防御側決定基準(Cumulative Probability Focus, Recent Pattern Focus, Counterattack Focus, Return Focus, Risk Avoidance Focus, Counter Focus, Distribution Focus)
25
+
26
+ ## 訓練情報
27
+
28
+ ### 訓練データ
29
+ - **データ数**: 479件(訓練)+ 25件(検証)
30
+ - **データソース**: game_rules_augmented.jsonl
31
+ - **データ形式**: Gemma-2-itプロンプトテンプレート形式
32
+ ```
33
+ <start_of_turn>user
34
+ 質問<end_of_turn>
35
+ <start_of_turn>model
36
+ 回答<end_of_turn>
37
+ ```
38
+
39
+ ### ハイパーパラメータ
40
+ | パラメータ | 値 |
41
+ |-----------|-----|
42
+ | ベースモデル | google/gemma-2-2b-it |
43
+ | LoRAランク (r) | 16 |
44
+ | LoRA alpha | 32 |
45
+ | LoRA dropout | 0.1 |
46
+ | ターゲットモジュール | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
47
+ | 学習率 | 5e-5 |
48
+ | バッチサイズ | 2 x 8 (gradient accumulation) = 16 |
49
+ | エポック数 | 37(途中停止) |
50
+ | 最適化手法 | AdamW |
51
+ | Warmup ratio | 0.3 |
52
+ | Weight decay | 0.05 |
53
+ | 精度 | bfloat16 |
54
+
55
+ ### 訓練結果
56
+ - **最終訓練ロス**: 0.0
57
+ - **最終検証ロス**: 1.08e-05
58
+ - **訓練可能パラメータ**: 20,766,720 (0.79%)
59
+ - **訓練時間**: 約1.5時間
60
+ - **ハードウェア**: NVIDIA RTX 4070 Ti SUPER (16GB VRAM)
61
+
62
+ ## 評価結果
63
+
64
+ ### テスト結果サマリー
65
+ 9つの異なる質問でテストを実施:
66
+
67
+ | 評価 | 件数 | 割合 |
68
+ |------|------|------|
69
+ | ✅ 完璧な回答 | 4/9 | 44% |
70
+ | ⚠️ 部分的に正確 | 1/9 | 11% |
71
+ | ❌ 不正確 | 4/9 | 44% |
72
+
73
+ ### 強み
74
+ ✅ **個別の決定基準の説明は非常に正確**
75
+ - Recent Pattern Focus, Counterattack Focus, Counter Focus, Distribution Focusの説明は完璧
76
+
77
+ ✅ **質問の表現バリエーションに対応**
78
+ - "What is", "Explain", "Describe", "Tell me about" など様々な動詞に対応可能
79
+
80
+ ### 弱点
81
+ ❌ **過学習による知識の混同**
82
+ - 数値の誤認(5個の戦略を7個と回答)
83
+ - 攻撃側/防御側の混同
84
+ - 戦略特徴の混入
85
+
86
+ ❌ **間接的な質問への対応不足**
87
+ - "Which strategy focuses on energy management?" → 不正確な回答
88
+
89
+ ❌ **比較質問への対応不足**
90
+ - 訓練データに比較形式の例がないため、適切な比較ができない
91
+
92
+ ## 使い方
93
+
94
+ ### インストール
95
+ ```bash
96
+ pip install transformers peft torch
97
+ ```
98
+
99
+ ### 基本的な使用方法
100
+ ```python
101
+ from transformers import AutoModelForCausalLM, AutoTokenizer
102
+ from peft import PeftModel
103
+ import torch
104
+
105
+ # ベースモデルとLoRAアダプタをロード
106
+ base_model = AutoModelForCausalLM.from_pretrained(
107
+ "google/gemma-2-2b-it",
108
+ device_map="auto",
109
+ torch_dtype=torch.bfloat16
110
+ )
111
+
112
+ model = PeftModel.from_pretrained(base_model, "ayousanz/gemma-2-2b-it-game-ft")
113
+ tokenizer = AutoTokenizer.from_pretrained("ayousanz/gemma-2-2b-it-game-ft")
114
+
115
+ # 推論
116
+ prompt = "What is the offensive strategy?"
117
+ formatted_prompt = f"<start_of_turn>user\n{prompt}<end_of_turn>\n<start_of_turn>model\n"
118
+
119
+ inputs = tokenizer(formatted_prompt, return_tensors="pt").to(model.device)
120
+ outputs = model.generate(
121
+ **inputs,
122
+ max_new_tokens=150,
123
+ do_sample=False,
124
+ pad_token_id=tokenizer.pad_token_id,
125
+ eos_token_id=tokenizer.eos_token_id
126
+ )
127
+
128
+ response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
129
+ print(response)
130
+ # 出力: Offensive strategy: High risk, high reward strategy type with frequent attacks.
131
+ ```
132
+
133
+ ### マージして使用(推奨)
134
+ ```python
135
+ # LoRAアダプタをベースモデルにマージ
136
+ merged_model = model.merge_and_unload()
137
+
138
+ # 推論(より高速)
139
+ inputs = tokenizer(formatted_prompt, return_tensors="pt").to(merged_model.device)
140
+ outputs = merged_model.generate(**inputs, max_new_tokens=150)
141
+ ```
142
+
143
+ ## 推奨される使用方法
144
+
145
+ ### ✅ 適している質問
146
+ - 個別の戦略や決定基準の説明
147
+ - "What is Recent Pattern Focus in offense?"
148
+ - "Explain Counterattack Focus in defense"
149
+ - 基本的な戦略タイプの説明
150
+ - "What is the offensive strategy?"
151
+ - "Tell me about Disruptive strategy"
152
+
153
+ ### ❌ 避けるべき質問
154
+ - 数を問う質問
155
+ - "How many basic strategy types are there?" → 不正確な可能性
156
+ - 比較質問
157
+ - "Compare offensive and defensive strategies" → 不適切な回答
158
+ - 間接的な質問
159
+ - "Which strategy focuses on X?" → 不正確な可能性
160
+
161
+ ## 制限事項と注意点
162
+
163
+ ### ⚠️ 過学習について
164
+ このモデルはエポック37で訓練されており、**過学習**の兆候があります:
165
+ - 訓練ロスが0.0まで低下
166
+ - 一部の知識が混同(数値、攻撃/防御の区別)
167
+ - 訓練データにない造語を生成する場合あり
168
+
169
+ ### 推奨事項
170
+ より正確なモデルが必要な場合は、以下のアプローチを推奨:
171
+ 1. **エポック数を10-15に削減して再訓練**
172
+ 2. **データの追加**(比較質問、間接質問の例を追加)
173
+ 3. **正則化の強化**(weight decay増加、LoRA dropout増加)
174
+
175
+ ## ライセンス
176
+
177
+ このモデルは以下のライセンスに従います:
178
+ - **コード**: MIT License
179
+ - **ベースモデル(Gemma-2)**: [Gemma Terms of Use](https://ai.google.dev/gemma/terms)に従ってください
180
+
181
+ ## 引用
182
+
183
+ このモデルを使用する場合は、以下を引用してください:
184
+
185
+ ```bibtex
186
+ @misc{gemma-2-2b-it-game-ft,
187
+ author = {ayousanz},
188
+ title = {Gemma-2-2B-IT Game Strategy Fine-tuning},
189
+ year = {2025},
190
+ publisher = {Hugging Face},
191
+ howpublished = {\url{https://huggingface.co/ayousanz/gemma-2-2b-it-game-ft}}
192
+ }
193
+ ```
194
+
195
+ ## 技術仕様
196
+
197
+ ### モデルアーキテクチャ
198
+ - **ベースモデル**: Gemma-2-2B-IT
199
+ - **ファインチューニング手法**: LoRA (Low-Rank Adaptation)
200
+ - **パラメータ効率**: 0.79% (20.7M / 2.6B)
201
+
202
+ ### 計算環境
203
+ - **GPU**: NVIDIA RTX 4070 Ti SUPER (16GB VRAM)
204
+ - **OS**: Windows 11
205
+ - **フレームワーク**:
206
+ - Transformers 4.47.1
207
+ - PEFT 0.17.1
208
+ - PyTorch 2.5.1+cu124
209
+
210
+ ## 連絡先
211
+
212
+ 問題や質問がある場合は、[Issues](https://huggingface.co/ayousanz/gemma-2-2b-it-game-ft/discussions)でお知らせください。
213
 
214
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
+ **🤖 このモデルは実験的なものです。本番環境での使用前に十分なテストを行ってください。**