junwatu commited on
Commit
42b357a
·
verified ·
1 Parent(s): c6a0aae

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +3 -5
  2. index.html +259 -0
README.md CHANGED
@@ -3,13 +3,10 @@ title: Resep ID Gemma 4
3
  emoji: 🍲
4
  colorFrom: red
5
  colorTo: yellow
6
- sdk: gradio
7
- sdk_version: 5.0.0
8
- python_version: 3.12
9
- app_file: app.py
10
  pinned: false
11
  license: gemma
12
- short_description: Gemma 4 fine-tuned models for Indonesian recipes
13
  models:
14
  - google/gemma-4-e2b-it
15
  - junwatu/resep-ID-gemma-4-E2B-it
@@ -307,6 +304,7 @@ Future cycles should be cheaper because the stack and gotchas are now documented
307
  - Fine-tuned model: [`junwatu/resep-ID-gemma-4-E2B-it`](https://huggingface.co/junwatu/resep-ID-gemma-4-E2B-it)
308
  - GGUF model: [`junwatu/resep-ID-gemma-4-E2B-it-gguf`](https://huggingface.co/junwatu/resep-ID-gemma-4-E2B-it-gguf)
309
  - Dataset: [`junwatu/indonesian-recipes`](https://huggingface.co/datasets/junwatu/indonesian-recipes)
 
310
 
311
  ## License
312
 
 
3
  emoji: 🍲
4
  colorFrom: red
5
  colorTo: yellow
6
+ sdk: static
 
 
 
7
  pinned: false
8
  license: gemma
9
+ short_description: Gemma 4 Indonesian recipe fine-tune case study
10
  models:
11
  - google/gemma-4-e2b-it
12
  - junwatu/resep-ID-gemma-4-E2B-it
 
304
  - Fine-tuned model: [`junwatu/resep-ID-gemma-4-E2B-it`](https://huggingface.co/junwatu/resep-ID-gemma-4-E2B-it)
305
  - GGUF model: [`junwatu/resep-ID-gemma-4-E2B-it-gguf`](https://huggingface.co/junwatu/resep-ID-gemma-4-E2B-it-gguf)
306
  - Dataset: [`junwatu/indonesian-recipes`](https://huggingface.co/datasets/junwatu/indonesian-recipes)
307
+ - Live recipe demo: [`junwatu/koki-ai`](https://huggingface.co/spaces/junwatu/koki-ai)
308
 
309
  ## License
310
 
index.html ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Resep ID Gemma 4</title>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ body { background: #1a1a2e; color: #e0e0e0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.7; padding: 2rem; }
10
+ .container { max-width: 860px; margin: 0 auto; }
11
+ h1 { color: #fff; font-size: 2rem; margin: 1.5rem 0 1rem; }
12
+ h2 { color: #ffa94d; font-size: 1.4rem; margin: 2rem 0 0.8rem; border-bottom: 1px solid #2a4a7f; padding-bottom: 0.4rem; }
13
+ h3 { color: #ddd; font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
14
+ p { margin: 0.6rem 0; }
15
+ a { color: #ffa94d; text-decoration: none; }
16
+ a:hover { text-decoration: underline; }
17
+ code { background: #0f3460; color: #a8dadc; padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }
18
+ pre { background: #0f3460; border: 1px solid #2a4a7f; border-radius: 6px; padding: 1rem; overflow-x: auto; margin: 1rem 0; }
19
+ pre code { background: none; padding: 0; }
20
+ blockquote { border-left: 3px solid #ffa94d; padding-left: 1rem; color: #bbb; margin: 1rem 0; }
21
+ table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
22
+ th, td { border: 1px solid #2a4a7f; padding: 0.5rem 0.8rem; text-align: left; }
23
+ th { background: #0f3460; color: #fff; }
24
+ tr:nth-child(even) { background: rgba(15,52,96,0.3); }
25
+ ul, ol { padding-left: 1.5rem; margin: 0.5rem 0; }
26
+ li { margin: 0.3rem 0; }
27
+ hr { border: none; border-top: 1px solid #2a4a7f; margin: 2rem 0; }
28
+ </style>
29
+ </head>
30
+ <body>
31
+ <div class="container">
32
+
33
+ <h1>🍲 Resep ID Gemma 4</h1>
34
+
35
+ <p>This Space explains an end-to-end fine-tuning project: taking <code>google/gemma-4-e2b-it</code>, adapting it to Indonesian recipe generation, evaluating the result, quantizing it to GGUF, and deploying it as a lightweight recipe assistant.</p>
36
+
37
+ <p>The goal was simple:</p>
38
+
39
+ <blockquote>Given an Indonesian dish title, generate a structured recipe with <code>Bahan:</code> and <code>Langkah:</code> in natural Bahasa Indonesia.</blockquote>
40
+
41
+ <p>Example input:</p>
42
+ <pre><code>Tulis resep masakan Indonesia berjudul: "Tumis Kangkung Tempe".</code></pre>
43
+
44
+ <p>Expected output shape:</p>
45
+ <pre><code>Bahan:
46
+ - ...
47
+ - ...
48
+
49
+ Langkah:
50
+ 1. ...
51
+ 2. ...</code></pre>
52
+
53
+ <h2>Project Summary</h2>
54
+ <table>
55
+ <tr><th>Item</th><th>Details</th></tr>
56
+ <tr><td>Base model</td><td><code>google/gemma-4-e2b-it</code></td></tr>
57
+ <tr><td>Fine-tuned model</td><td><code>junwatu/resep-ID-gemma-4-E2B-it</code></td></tr>
58
+ <tr><td>GGUF model</td><td><code>junwatu/resep-ID-gemma-4-E2B-it-gguf</code></td></tr>
59
+ <tr><td>Dataset</td><td><code>junwatu/indonesian-recipes</code></td></tr>
60
+ <tr><td>Task</td><td>Indonesian recipe generation</td></tr>
61
+ <tr><td>Training hardware</td><td>AMD Instinct MI300X</td></tr>
62
+ <tr><td>GPU memory</td><td>192 GB HBM3 class</td></tr>
63
+ <tr><td>Software stack</td><td>ROCm 7.2, PyTorch ROCm wheel, Transformers 5.x, TRL 1.x</td></tr>
64
+ <tr><td>Training method</td><td>Full supervised fine-tune</td></tr>
65
+ <tr><td>Training data</td><td>66,419 recipes</td></tr>
66
+ <tr><td>Validation data</td><td>1,748 recipes</td></tr>
67
+ <tr><td>Held-out test data</td><td>1,748 recipes</td></tr>
68
+ <tr><td>Final deployment format</td><td>Safetensors + GGUF Q4_K_M / Q8_0</td></tr>
69
+ </table>
70
+
71
+ <h2>Why Fine-Tune?</h2>
72
+ <p>The base Gemma 4 model was already fluent in Indonesian, but it often missed the identity of specific Indonesian dishes.</p>
73
+ <p>For example, the base model could produce a plausible recipe, but not always the <em>right</em> recipe. It struggled with regional or highly specific dishes such as:</p>
74
+ <ul>
75
+ <li>Sosis Solo</li>
76
+ <li>Tahu Thek</li>
77
+ <li>Tempe Mendoan</li>
78
+ <li>Tahu Walik Aci</li>
79
+ <li>Kering Tempe Pete</li>
80
+ <li>DEBM / MPASI recipe variants</li>
81
+ </ul>
82
+
83
+ <p>A baseline evaluation on 50 held-out recipes showed the main gap:</p>
84
+ <table>
85
+ <tr><th>Dimension</th><th>Base Gemma 4 E2B</th></tr>
86
+ <tr><td>Language fidelity</td><td>5.00</td></tr>
87
+ <tr><td>Format compliance</td><td>3.90</td></tr>
88
+ <tr><td>Ingredient plausibility</td><td>3.10</td></tr>
89
+ <tr><td>Step coherence</td><td>3.20</td></tr>
90
+ <tr><td>Dish authenticity</td><td>2.70</td></tr>
91
+ <tr><td>Overall</td><td>3.58</td></tr>
92
+ </table>
93
+ <p>The key weakness was <code>dish_authenticity</code>: the model was fluent, but too often produced a generic Indonesian recipe instead of the requested dish.</p>
94
+
95
+ <h2>Dataset</h2>
96
+ <p>The dataset contains structured Indonesian home-cooking recipes. Each row has:</p>
97
+ <table>
98
+ <tr><th>Field</th><th>Description</th></tr>
99
+ <tr><td><code>title</code></td><td>Recipe name</td></tr>
100
+ <tr><td><code>ingredients</code></td><td>List of ingredient lines</td></tr>
101
+ <tr><td><code>steps</code></td><td>Ordered cooking steps</td></tr>
102
+ <tr><td><code>num_ingredients</code></td><td>Ingredient count</td></tr>
103
+ <tr><td><code>num_steps</code></td><td>Step count</td></tr>
104
+ <tr><td><code>char_count</code></td><td>Approximate recipe length</td></tr>
105
+ </table>
106
+
107
+ <p>The project converts the original parquet files into JSONL splits:</p>
108
+ <pre><code>data/processed/train.jsonl
109
+ data/processed/val.jsonl
110
+ data/processed/test.jsonl</code></pre>
111
+ <p>The held-out test split is not used for training. It is used only for pre/post fine-tune comparison.</p>
112
+
113
+ <h2>Training Setup</h2>
114
+ <p>The fine-tune used a single AMD MI300X GPU on ROCm 7.2. Important training choices:</p>
115
+ <ul>
116
+ <li>Full fine-tune instead of LoRA</li>
117
+ <li>bf16 training</li>
118
+ <li>1 epoch</li>
119
+ <li>Effective batch size 16</li>
120
+ <li>Max sequence length 2048</li>
121
+ <li>Cosine learning-rate schedule</li>
122
+ <li>3% warmup</li>
123
+ <li>Gradient checkpointing enabled</li>
124
+ <li>Vision/audio paths frozen because this task is text-only</li>
125
+ </ul>
126
+
127
+ <p>Gemma 4 is multimodal, but this project trains only the text path:</p>
128
+ <pre><code>Train:
129
+ - model.language_model.*
130
+ - lm_head
131
+
132
+ Freeze:
133
+ - vision tower
134
+ - audio tower
135
+ - vision/audio adapters</code></pre>
136
+
137
+ <h2>Training Format</h2>
138
+ <p>The project uses TRL prompt/completion conversational format:</p>
139
+ <pre><code>{
140
+ "prompt": [
141
+ {
142
+ "role": "user",
143
+ "content": "Tulis resep masakan Indonesia berjudul: \"Tumis Kangkung Tempe\"..."
144
+ }
145
+ ],
146
+ "completion": [
147
+ {
148
+ "role": "assistant",
149
+ "content": "Bahan:\n- ...\n\nLangkah:\n1. ..."
150
+ }
151
+ ]
152
+ }</code></pre>
153
+ <p>This format was important. In this stack, the alternative <code>messages</code> format with <code>assistant_only_loss=True</code> caused unstable loss behavior.</p>
154
+
155
+ <h2>Results</h2>
156
+ <p>The fine-tuned model improved the practical recipe-generation behavior.</p>
157
+ <table>
158
+ <tr><th>Dimension</th><th>Base</th><th>Fine-tuned</th></tr>
159
+ <tr><td>Language fidelity</td><td>5.00</td><td>~4.6</td></tr>
160
+ <tr><td>Format compliance</td><td>3.90</td><td>~4.95</td></tr>
161
+ <tr><td>Ingredient plausibility</td><td>3.10</td><td>~3.5</td></tr>
162
+ <tr><td>Step coherence</td><td>3.20</td><td>~3.9</td></tr>
163
+ <tr><td>Dish authenticity</td><td>2.70</td><td>~3.25</td></tr>
164
+ <tr><td>Overall</td><td>3.58</td><td>~4.0</td></tr>
165
+ </table>
166
+
167
+ <p>The strongest gains were:</p>
168
+ <ul>
169
+ <li>More consistent <code>Bahan:</code> / <code>Langkah:</code> formatting</li>
170
+ <li>Better recipe length discipline</li>
171
+ <li>More natural Indonesian cooking vocabulary</li>
172
+ <li>Better common-dish ingredient profiles</li>
173
+ <li>Better structure for common dishes like tumis, pepes, rendang, sambal, and gulai</li>
174
+ </ul>
175
+
176
+ <h2>Critical Inference Setting</h2>
177
+ <p>One important lesson from the project: the fine-tuned model needs repetition control.</p>
178
+ <pre><code>model.generate(
179
+ **inputs,
180
+ max_new_tokens=1280,
181
+ do_sample=False,
182
+ repetition_penalty=1.05,
183
+ no_repeat_ngram_size=6,
184
+ pad_token_id=tok.eos_token_id,
185
+ )</code></pre>
186
+ <p>Without <code>no_repeat_ngram_size=6</code>, long recipes can fall into repeated ingredient-list loops.</p>
187
+ <p>For GGUF runtimes such as llama.cpp or LM Studio, use the DRY sampler equivalent with allowed length around 6.</p>
188
+
189
+ <h2>GGUF Deployment</h2>
190
+ <p>The model was also converted to GGUF for local and CPU-friendly use.</p>
191
+ <table>
192
+ <tr><th>Quant</th><th>Approx. size</th><th>Use case</th></tr>
193
+ <tr><td>Q4_K_M</td><td>~3.2 GB</td><td>Default portable version</td></tr>
194
+ <tr><td>Q8_0</td><td>~4.7 GB</td><td>Higher quality, more RAM</td></tr>
195
+ </table>
196
+ <p>The GGUF model can run with llama.cpp, LM Studio, or other GGUF-compatible runtimes.</p>
197
+
198
+ <h2>What Worked</h2>
199
+ <p>The project worked well for:</p>
200
+ <ul>
201
+ <li>Common Indonesian home-cooking recipes</li>
202
+ <li>Structured recipe generation</li>
203
+ <li>Concise recipe output</li>
204
+ <li>Natural Indonesian recipe phrasing</li>
205
+ <li>Common ingredients and cooking methods</li>
206
+ </ul>
207
+ <p>Examples of stronger categories: Ayam, Ikan, Sapi, Kambing, Tahu, Tempe, Telur, Udang, Sambal, Tumis, Pepes, Rendang-style dishes.</p>
208
+
209
+ <h2>Limitations</h2>
210
+ <ul>
211
+ <li>Rare regional dishes can become generic.</li>
212
+ <li>Some defining ingredients may be omitted.</li>
213
+ <li>Diet or modifier terms such as MPASI, DEBM, basah, or kering may be ignored.</li>
214
+ <li>The model may produce plausible but not authentic recipes.</li>
215
+ <li>Some outputs may contain minor formatting or fraction glitches.</li>
216
+ <li>Recipes should be checked before cooking.</li>
217
+ </ul>
218
+ <p>The main remaining bottleneck is dataset coverage, especially for regional and specialty dishes.</p>
219
+
220
+ <h2>Lessons Learned</h2>
221
+ <ol>
222
+ <li>Use the native ROCm 7.2 PyTorch wheel on MI300X.</li>
223
+ <li>Avoid older ROCm wheels for this Gemma 4 bf16 training path.</li>
224
+ <li>Use prompt/completion format with TRL for this stack.</li>
225
+ <li>Always run a cheap quick-validation training pass before a full run.</li>
226
+ <li>Judge the base model before fine-tuning.</li>
227
+ <li>Automatic metrics are not enough for recipe quality.</li>
228
+ <li><code>no_repeat_ngram_size=6</code> is critical for stable inference.</li>
229
+ <li>Dataset coverage matters more than another epoch for rare dishes.</li>
230
+ </ol>
231
+
232
+ <h2>Cost and Runtime</h2>
233
+ <table>
234
+ <tr><th>Phase</th><th>Approx. cost</th></tr>
235
+ <tr><td>Setup and debugging</td><td>~$2.50</td></tr>
236
+ <tr><td>Quick validation</td><td>~$1.50</td></tr>
237
+ <tr><td>Full training</td><td>~$3.00</td></tr>
238
+ <tr><td>Evaluation iterations</td><td>~$2.00</td></tr>
239
+ <tr><td>GGUF conversion and upload</td><td>~$1.30</td></tr>
240
+ <tr><td>Idle/debugging slack</td><td>~$4.00</td></tr>
241
+ <tr><td><strong>Total</strong></td><td><strong>~$14</strong></td></tr>
242
+ </table>
243
+ <p>Future cycles should be cheaper because the stack and gotchas are now documented.</p>
244
+
245
+ <h2>Links</h2>
246
+ <ul>
247
+ <li>Base model: <a href="https://huggingface.co/google/gemma-4-e2b-it">google/gemma-4-e2b-it</a></li>
248
+ <li>Fine-tuned model: <a href="https://huggingface.co/junwatu/resep-ID-gemma-4-E2B-it">junwatu/resep-ID-gemma-4-E2B-it</a></li>
249
+ <li>GGUF model: <a href="https://huggingface.co/junwatu/resep-ID-gemma-4-E2B-it-gguf">junwatu/resep-ID-gemma-4-E2B-it-gguf</a></li>
250
+ <li>Dataset: <a href="https://huggingface.co/datasets/junwatu/indonesian-recipes">junwatu/indonesian-recipes</a></li>
251
+ <li>Live recipe demo: <a href="https://huggingface.co/spaces/junwatu/koki-ai">junwatu/koki-ai</a></li>
252
+ </ul>
253
+
254
+ <hr>
255
+ <p><em>This project inherits the Gemma Terms of Use from the base model.</em></p>
256
+
257
+ </div>
258
+ </body>
259
+ </html>