hwding commited on
Commit
38f8bec
·
verified ·
1 Parent(s): 7572a81

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +329 -32
README.md CHANGED
@@ -1,62 +1,359 @@
1
  ---
 
 
 
2
  base_model: deepseek-ai/deepseek-coder-6.7b-instruct
3
- library_name: peft
4
- model_name: forge-coder-v1.21.11
5
  tags:
6
- - base_model:adapter:deepseek-ai/deepseek-coder-6.7b-instruct
7
- - lora
8
- - sft
9
- - transformers
10
- - trl
11
- licence: license
 
 
 
 
 
 
12
  pipeline_tag: text-generation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ---
14
 
15
- # Model Card for forge-coder-v1.21.11
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- This model is a fine-tuned version of [deepseek-ai/deepseek-coder-6.7b-instruct](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-instruct).
18
- It has been trained using [TRL](https://github.com/huggingface/trl).
 
 
 
 
 
 
 
 
19
 
20
- ## Quick start
 
 
 
 
 
 
 
 
21
 
22
  ```python
23
- from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
26
- generator = pipeline("text-generation", model="None", device="cuda")
27
- output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
28
- print(output["generated_text"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ```
30
 
31
- ## Training procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
-
 
 
 
 
 
34
 
 
35
 
36
- This model was trained with SFT.
37
 
38
- ### Framework versions
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- - PEFT 0.18.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  - TRL: 0.26.1
42
  - Transformers: 4.57.3
43
- - Pytorch: 2.5.1+cu121
44
  - Datasets: 4.4.1
45
  - Tokenizers: 0.22.1
46
 
47
- ## Citations
 
 
 
 
 
 
 
48
 
 
 
 
 
 
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  Cite TRL as:
52
-
53
  ```bibtex
54
  @misc{vonwerra2022trl,
55
- title = {{TRL: Transformer Reinforcement Learning}},
56
- author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
57
- year = 2020,
58
- journal = {GitHub repository},
59
- publisher = {GitHub},
60
- howpublished = {\url{https://github.com/huggingface/trl}}
61
  }
62
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: other
3
+ license_name: deepseek-license
4
+ license_link: https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/LICENSE-MODEL
5
  base_model: deepseek-ai/deepseek-coder-6.7b-instruct
 
 
6
  tags:
7
+ - minecraft
8
+ - forge
9
+ - modding
10
+ - code-generation
11
+ - lora
12
+ - peft
13
+ - sft
14
+ - trl
15
+ language:
16
+ - en
17
+ - code
18
+ library_name: peft
19
  pipeline_tag: text-generation
20
+ datasets:
21
+ - custom
22
+ model-index:
23
+ - name: forge-coder-v1.21.11
24
+ results: []
25
+ ---
26
+
27
+ <div align="center">
28
+ <h1>🔨 Forge Coder v1.21.11</h1>
29
+ <p><strong>A Specialized Code Generation Model for Minecraft Forge Mod Development</strong></p>
30
+ <p>
31
+ <a href="#quickstart">Quick Start</a> •
32
+ <a href="#capabilities">Capabilities</a> •
33
+ <a href="#examples">Examples</a> •
34
+ <a href="#training">Training Details</a>
35
+ </p>
36
+ </div>
37
+
38
  ---
39
 
40
+ ## Overview
41
+
42
+ **Forge Coder** is a fine-tuned large language model specifically designed to assist developers in creating Minecraft Forge mods. Built on top of DeepSeek Coder 6.7B, this model has been trained on extensive Forge mod source code and documentation to provide accurate, idiomatic, and up-to-date code generation for Minecraft modding.
43
+
44
+ ### Key Features
45
+
46
+ - 🎯 **Specialized Knowledge**: Deep understanding of Forge API, registry systems, and modding patterns
47
+ - 🔄 **Version-Aligned**: Trained specifically for Minecraft 1.21.11 and Forge 1.21.11
48
+ - 💡 **Code Completion**: Generate complete mod components from natural language descriptions
49
+ - 📚 **Best Practices**: Follows modern Forge modding conventions and patterns
50
+
51
+ ## Model Details
52
 
53
+ | Property | Value |
54
+ |----------|-------|
55
+ | **Base Model** | [deepseek-ai/deepseek-coder-6.7b-instruct](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-instruct) |
56
+ | **Fine-tuning Method** | QLoRA (4-bit quantization + LoRA) |
57
+ | **LoRA Rank** | 64 |
58
+ | **LoRA Alpha** | 128 |
59
+ | **Trainable Parameters** | 159.9M (2.3% of 6.7B) |
60
+ | **Target Forge Version** | 1.21.11 |
61
+ | **Target Minecraft Version** | 1.21.11 |
62
+ | **MCP Mappings** | 20251209.095502 |
63
 
64
+ ## Quickstart
65
+
66
+ ### Installation
67
+
68
+ ```bash
69
+ pip install transformers peft accelerate bitsandbytes torch
70
+ ```
71
+
72
+ ### Basic Usage
73
 
74
  ```python
75
+ import torch
76
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
77
+ from peft import PeftModel
78
+
79
+ # Quantization config for efficient inference
80
+ bnb_config = BitsAndBytesConfig(
81
+ load_in_4bit=True,
82
+ bnb_4bit_quant_type="nf4",
83
+ bnb_4bit_compute_dtype=torch.bfloat16,
84
+ bnb_4bit_use_double_quant=True,
85
+ )
86
+
87
+ # Load model
88
+ base_model_id = "deepseek-ai/deepseek-coder-6.7b-instruct"
89
+ adapter_id = "hwding/forge-coder-v1.21.11"
90
+
91
+ tokenizer = AutoTokenizer.from_pretrained(adapter_id)
92
+ model = AutoModelForCausalLM.from_pretrained(
93
+ base_model_id,
94
+ quantization_config=bnb_config,
95
+ device_map="auto",
96
+ )
97
+ model = PeftModel.from_pretrained(model, adapter_id)
98
+
99
+ # Generate code
100
+ def generate_forge_code(prompt: str, max_tokens: int = 1024) -> str:
101
+ messages = f"""### System:
102
+ You are an expert Minecraft Forge mod developer for version 1.21.11. Write clean, efficient, and well-structured Java code.
103
+
104
+ ### User:
105
+ {prompt}
106
+
107
+ ### Assistant:
108
+ """
109
+ inputs = tokenizer(messages, return_tensors="pt").to(model.device)
110
+ outputs = model.generate(
111
+ **inputs,
112
+ max_new_tokens=max_tokens,
113
+ temperature=0.7,
114
+ top_p=0.95,
115
+ do_sample=True,
116
+ pad_token_id=tokenizer.eos_token_id,
117
+ )
118
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
119
+
120
+ # Example
121
+ code = generate_forge_code("Create a custom ore block that drops experience when mined")
122
+ print(code)
123
+ ```
124
+
125
+ ## Capabilities
126
+
127
+ The model excels at generating code for various Forge mod components:
128
+
129
+ | Category | Examples |
130
+ |----------|----------|
131
+ | **Blocks** | Custom blocks, ore blocks, machine blocks, multi-blocks |
132
+ | **Items** | Tools, weapons, armor, food items, custom items |
133
+ | **Entities** | Mobs, projectiles, vehicles, tile entities |
134
+ | **GUI/Screens** | Container menus, custom screens, HUD elements |
135
+ | **Networking** | Packet handling, client-server sync |
136
+ | **World Generation** | Ore generation, structures, biomes, features |
137
+ | **Events** | Forge event handlers, lifecycle events |
138
+ | **Registries** | DeferredRegister patterns, registry objects |
139
+ | **Capabilities** | Custom capabilities, capability providers |
140
+ | **Recipes** | Custom recipe types, recipe serializers |
141
+ | **Data Generation** | Datagen for models, blockstates, loot tables, tags |
142
+ | **Rendering** | Block/item/entity renderers, shaders |
143
+
144
+ ## Examples
145
+
146
+ ### Creating a Custom Block
147
+
148
+ **Prompt:** "Create a copper lamp block that emits light when powered by redstone"
149
+
150
+ ```java
151
+ public class CopperLampBlock extends Block {
152
+ public static final BooleanProperty LIT = BlockStateProperties.LIT;
153
+
154
+ public CopperLampBlock(Properties properties) {
155
+ super(properties);
156
+ this.registerDefaultState(this.stateDefinition.any().setValue(LIT, false));
157
+ }
158
+
159
+ @Override
160
+ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
161
+ builder.add(LIT);
162
+ }
163
+
164
+ @Override
165
+ public void neighborChanged(BlockState state, Level level, BlockPos pos,
166
+ Block block, BlockPos fromPos, boolean isMoving) {
167
+ if (!level.isClientSide) {
168
+ boolean powered = level.hasNeighborSignal(pos);
169
+ if (powered != state.getValue(LIT)) {
170
+ level.setBlock(pos, state.setValue(LIT, powered), 2);
171
+ }
172
+ }
173
+ }
174
+
175
+ @Override
176
+ public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) {
177
+ return state.getValue(LIT) ? 15 : 0;
178
+ }
179
+ }
180
+ ```
181
+
182
+ ### Creating a Custom Item
183
 
184
+ **Prompt:** "Create a magic wand item that shoots fireballs on right click"
185
+
186
+ ```java
187
+ public class MagicWandItem extends Item {
188
+ public MagicWandItem(Properties properties) {
189
+ super(properties.stacksTo(1).durability(100));
190
+ }
191
+
192
+ @Override
193
+ public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
194
+ ItemStack stack = player.getItemInHand(hand);
195
+
196
+ if (!level.isClientSide) {
197
+ Vec3 look = player.getLookAngle();
198
+ SmallFireball fireball = new SmallFireball(level, player, look.x, look.y, look.z);
199
+ fireball.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
200
+ level.addFreshEntity(fireball);
201
+
202
+ stack.hurtAndBreak(1, player, (p) -> p.broadcastBreakEvent(hand));
203
+ player.getCooldowns().addCooldown(this, 20);
204
+ }
205
+
206
+ level.playSound(player, player.blockPosition(), SoundEvents.BLAZE_SHOOT,
207
+ SoundSource.PLAYERS, 1.0F, 1.0F);
208
+
209
+ return InteractionResultHolder.sidedSuccess(stack, level.isClientSide);
210
+ }
211
+ }
212
  ```
213
 
214
+ ## Training Data
215
+
216
+ ### Data Sources
217
+
218
+ | Source | Description | Files |
219
+ |--------|-------------|-------|
220
+ | **Forge Source** | MinecraftForge core, ForgeGradle, EventBus, ModLauncher | ~1,200 |
221
+ | **Popular Mods** | 27 well-maintained open-source mod repositories | ~21,700 |
222
+ | **Documentation** | Official Forge docs and tutorials | 74 |
223
+
224
+ ### Featured Mod Repositories
225
+
226
+ Training data includes code from highly-regarded mods:
227
+
228
+ - **Applied Energistics 2** - Storage & automation
229
+ - **Mekanism** - Tech & machinery
230
+ - **Create** - Mechanical contraptions
231
+ - **Botania** - Nature magic
232
+ - **Thermal Series** - Energy systems
233
+ - **Tinkers' Construct** - Tool crafting
234
+ - **Immersive Engineering** - Industrial machines
235
+ - **JustEnoughItems (JEI)** - Recipe viewing
236
+ - **TerraFirmaCraft** - Survival overhaul
237
+ - **The Twilight Forest** - Dimension mod
238
+ - **Quark** - Vanilla enhancements
239
+ - **RFTools** - RF-powered utilities
240
+ - And 15 more...
241
+
242
+ ### Dataset Statistics
243
 
244
+ | Metric | Value |
245
+ |--------|-------|
246
+ | Total Java Files Processed | 22,916 |
247
+ | Training Samples | 13,936 |
248
+ | Validation Samples | 734 |
249
+ | Sample Types | Code completion, explanation, Q&A |
250
 
251
+ ## Training
252
 
253
+ ### Configuration
254
 
255
+ | Parameter | Value |
256
+ |-----------|-------|
257
+ | Epochs | 3 |
258
+ | Batch Size | 2 (per device) |
259
+ | Gradient Accumulation | 8 steps |
260
+ | Effective Batch Size | 128 |
261
+ | Learning Rate | 2e-4 |
262
+ | LR Scheduler | Cosine |
263
+ | Warmup Ratio | 3% |
264
+ | Max Sequence Length | 2,048 tokens |
265
+ | Precision | BF16 |
266
+ | Hardware | 8× NVIDIA H20 (96GB each) |
267
 
268
+ ### Training Metrics
269
+
270
+ | Metric | Value |
271
+ |--------|-------|
272
+ | Training Duration | 9h 12m |
273
+ | Total Steps | 1,848 |
274
+ | Final Training Loss | 0.27 |
275
+ | Final Validation Loss | 0.325 |
276
+ | Token Accuracy | 92.5% |
277
+ | Eval Accuracy | 91.2% |
278
+
279
+ ### Loss Curve
280
+
281
+ ```
282
+ Epoch 1: 0.89 → 0.42
283
+ Epoch 2: 0.38 → 0.31
284
+ Epoch 3: 0.29 → 0.27
285
+ ```
286
+
287
+ ### Framework Versions
288
+
289
+ - PEFT: 0.18.0
290
  - TRL: 0.26.1
291
  - Transformers: 4.57.3
292
+ - PyTorch: 2.5.1+cu121
293
  - Datasets: 4.4.1
294
  - Tokenizers: 0.22.1
295
 
296
+ ## Limitations
297
+
298
+ - **Version Specific**: Optimized for Forge 1.21.11; may produce outdated patterns for older versions
299
+ - **Java Only**: Does not generate Kotlin, Gradle scripts, or JSON resources
300
+ - **No Runtime Testing**: Generated code should be tested before use in production
301
+ - **Context Window**: Limited to 2,048 tokens; very large classes may need to be split
302
+
303
+ ## Intended Use
304
 
305
+ ✅ **Recommended Uses:**
306
+ - Learning Forge modding patterns and best practices
307
+ - Rapid prototyping of mod components
308
+ - Code completion and suggestions
309
+ - Understanding Forge API usage
310
 
311
+ ⚠️ **Not Recommended For:**
312
+ - Production code without review
313
+ - Security-critical applications
314
+ - Forge versions significantly different from 1.21.11
315
+
316
+ ## Citation
317
+
318
+ If you use this model in your research or projects, please cite:
319
+
320
+ ```bibtex
321
+ @misc{forge-coder-2024,
322
+ author = {hwding},
323
+ title = {Forge Coder: A Specialized Code Generation Model for Minecraft Forge Mod Development},
324
+ year = {2024},
325
+ publisher = {Hugging Face},
326
+ url = {https://huggingface.co/hwding/forge-coder-v1.21.11}
327
+ }
328
+ ```
329
 
330
  Cite TRL as:
331
+
332
  ```bibtex
333
  @misc{vonwerra2022trl,
334
+ title = {{TRL: Transformer Reinforcement Learning}},
335
+ author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
336
+ year = 2020,
337
+ journal = {GitHub repository},
338
+ publisher = {GitHub},
339
+ howpublished = {\url{https://github.com/huggingface/trl}}
340
  }
341
+ ```
342
+
343
+ ## License
344
+
345
+ This model is released under the [DeepSeek License](https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/LICENSE-MODEL), consistent with the base model.
346
+
347
+ Training data was sourced from open-source repositories under various permissive licenses (MIT, Apache 2.0, LGPL, etc.).
348
+
349
+ ## Acknowledgments
350
+
351
+ - [DeepSeek](https://github.com/deepseek-ai) for the excellent base model
352
+ - [MinecraftForge](https://github.com/MinecraftForge) team for the modding framework
353
+ - All open-source mod developers whose code made this training possible
354
+
355
+ ---
356
+
357
+ <div align="center">
358
+ <p><strong>Happy Modding! 🎮⛏️</strong></p>
359
+ </div>