Views
No views yet
1# y-gemma4-svg-lora-enhanced
2
3QLoRA adapter for **Y**, a local-first AI whiteboard tutor built for the [Gemma 4 Good Hackathon](https://www.kaggle.com/competitions/gemma-4-good-hackathon).
4
5This adapter fine-tunes Gemma 4 E4B to emit an SVG-native whiteboard tutoring DSL:
6
7- `[text: "..."]` for narrated whiteboard captions
8- `[draw_part: name="..." viewBox="..."]` for named diagram parts
9- raw SVG path-data or whitelisted SVG elements per line
10- `[/draw_part]` to close each drawable part
11
12The goal is to move Y toward a tutor that can write and draw step-by-step on a whiteboard, closer to how a human teacher explains visual ideas.
13
14## Base Model
15
16Finetuned from:
17
18`unsloth/gemma-4-e4b-it-unsloth-bnb-4bit`
19
20The notebook loads the model through `FastVisionModel` so the saved adapter + processor remain compatible with multimodal whiteboard inputs at inference time.
21
22## Dataset
23
24Trained on a prepared SVG tutoring dataset built from `duxiaodan/ControlSketch-Part` using Y's dataset preparation pipeline.
25
26Final training set:
27
28- 400 prepared ControlSketch-Part rows
29- +40 repeated high-quality syntax anchors
30- 440 total training rows
31
32The anchors overrepresent exact tool syntax for examples such as Pythagorean theorem, free-body diagrams, benzene, animal cells, and DFS trees.
33
34## Training Config
35
36- Framework: Unsloth
37- Base: `unsloth/gemma-4-e4b-it-unsloth-bnb-4bit`
38- Method: QLoRA
39- Loader: `FastVisionModel`
40- Sequence length: `4096`
41- LoRA rank: `r=16`
42- LoRA alpha: `32`
43- LoRA dropout: `0`
44- Bias: `none`
45- Target modules: `all-linear`
46- Vision layers: frozen
47- Audio layers: frozen
48- Language layers: trained
49- Attention modules: trained
50- MLP modules: trained
51- Optimizer: AdamW 8-bit
52- Learning rate: `1.5e-4`
53- Warmup steps: `10`
54- Weight decay: `0.01`
55- LR schedule: linear
56- Batch size: `2`
57- Gradient accumulation: `4`
58- Effective batch size: `8`
59- Epochs: `6`
60- Total steps: `330`
61- Trainable params: `41,222,144 / 8,037,378,592` (`0.51%`)
62- Runtime: `3:14:56` on Kaggle T4
63- Seed: `3407`
64
65Training used `train_on_responses_only`, so loss was computed only on assistant/tool-output tokens, not on the system/user prompt.
66
67## Training Loss
68
69| Step | Loss |
70| --- | --- |
71| 10 | 1.3668 |
72| 20 | 0.4403 |
73| 50 | 0.3260 |
74| 100 | 0.2840 |
75| 150 | 0.2740 |
76| 200 | 0.2650 |
77| 250 | 0.2627 |
78| 300 | 0.2599 |
79| 330 | 0.2595 |
80
81## Sanity Check
82
83Held-out prompt:
84
85```text
86Draw a benzene ring with alternating bonds, decomposing into named parts.1[draw_part: benzene ring with alternating bonds]
2[draw_part: central hexagon]
3[draw_part: six carbon atoms at vertices]
4[draw_part: alternating single and double bonds]
5[/draw_part]<turn|>12.36 sdraw_part-style structure, though the output is still early and needs stricter validation/repair before being used as the default renderer.1from unsloth import FastVisionModel
2
3model, processor = FastVisionModel.from_pretrained(
4 model_name="QuantumTransformer/y-gemma4-svg-lora-enhanced",
5 max_seq_length=4096,
6 load_in_4bit=True,
7)
8
9FastVisionModel.for_inference(model)1[text: "First draw the carbon skeleton."]
2[draw_part: name="carbon skeleton" viewBox="0 0 400 300"]
3M 200 80 L 280 130 L 280 220 L 200 270 L 120 220 L 120 130 Z
4[/draw_part]
5[text: "Now add the alternating bonds."]
6[draw_part: name="alternating bonds" viewBox="0 0 400 300"]
7M 210 95 L 265 130
8M 265 220 L 210 255
9M 135 130 L 190 95
10[/draw_part]