kylebrodeur commited on
Commit
488ed6c
·
verified ·
1 Parent(s): 9800f7d

Add Microfactory Node field notes dataset card

Browse files
Files changed (1) hide show
  1. README.md +153 -0
README.md ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - build-small-hackathon
5
+ - backyard-ai
6
+ - field-notes
7
+ - microfactory-node
8
+ - 3d-printing
9
+ - small-models
10
+ - agent-trace
11
+ - multi-agent
12
+ ---
13
+
14
+ # Field Notes: Building a Shop-Floor AI on a Small Local Model
15
+
16
+ I spent ten days building a small local **Gemma** that learns 3D printing job by
17
+ job, and these are the notes from doing it. The one moment worth watching: it
18
+ reads today's room, pulls up the closest prior jobs, and either applies what they
19
+ taught — *"humidity is higher than the job where this overhang sagged, so I'm
20
+ raising retraction and adding support"* — or says, plainly, *"no close
21
+ precedent."* Two named agents keep it honest: Chief Engineer O'Brien proposes,
22
+ La Forge inspects.
23
+
24
+ This is a proof of concept that works, not a production system, and it was built
25
+ that way on purpose. The hackathon judges a demo, a writeup, a working app, and
26
+ a believable *someone could use this* story — so anything nobody judges never
27
+ got more effort than something that did. Simplify as you go. What follows is what
28
+ that discipline actually taught me.
29
+
30
+ ## 1. Small models need a spine, not a leash
31
+
32
+ The single best architectural decision: the model proposes, deterministic code
33
+ disposes. The **Spine** validates every proposed setting against hardcoded
34
+ material bounds. PLA nozzle at 260°C gets clamped to 220°C and a human gate
35
+ trips. Once that boundary exists, you stop prompt-engineering for safety and let
36
+ the model do the thing it is actually good at — judgment over precedent — without
37
+ betting the printer on it. Never ask a small model to be its own safety system.
38
+ Constraints are what make it trustworthy.
39
+
40
+ ## 2. Steering a small Gemma is a discipline
41
+
42
+ Everything in the steering playbook earned its place: a role-locked persona
43
+ ("you do not hype"), JSON mode with an output contract and cleanup code behind
44
+ it, pre-filtered context (the ledger hands the model two or three relevant
45
+ precedents, never the whole history), and a typed fallback for every call so a
46
+ parse failure costs one shrug, not a crash. Prompt budget matters more than
47
+ context window. Attention quality sags past about 800 tokens, so the hot-path
48
+ prompt stays near 600 and the preflight gate measures it.
49
+
50
+ ## 3. Two agents are more honest than one
51
+
52
+ O'Brien proposes the plan. La Forge, a separate skeptical persona, reads it
53
+ before anything prints and says where the optimism is thin. When La Forge
54
+ disputes, the print is held until the human acknowledges. O'Brien is the
55
+ optimist. La Forge is not. The model is never allowed to grade its own homework.
56
+ This cost almost nothing to add: one extra call, same model, a different system
57
+ prompt. It changes the trust story. The system is not asking you to believe one
58
+ agent grading itself. It shows you two views and makes the human decide.
59
+
60
+ ## 4. "Effective parameters" is a real thing you have to explain
61
+
62
+ I worked with **Gemma 4 E-class** from the start — `gemma4:e2b` and
63
+ `gemma4:e4b`, and later the QAT variants. The E-models report about 8B raw
64
+ parameters but run as effective ~4B or ~2B, because the architecture (MatFormer)
65
+ nests a smaller model inside a larger one. The preflight initially read the raw
66
+ count and told us to skip the small-model badge. Know which number your model
67
+ actually is, and prefer the variant that needs no argument: E4B is ~4B
68
+ effective, comfortably a small model.
69
+
70
+ ## 5. Latency warnings should be calibrated by driving, not by vibes
71
+
72
+ The gate said "too slow" at 18 s a turn. Then I drove the cockpit. A narrated
73
+ demo where you talk through the model's precedent evaluation while it thinks
74
+ reads fine at 18 s, and the 40 s first call is a one-time model load you
75
+ pre-warm away. The gate was recalibrated to match the observed experience: warm
76
+ under 20 s passes. Benchmarks exist to predict the experience. When the
77
+ experience disagrees, the benchmark is wrong.
78
+
79
+ ## 6. The smaller model was twice as fast, and made a physics mistake
80
+
81
+ E2B answered in 10 s where E4B took 18, and both passed every contract and
82
+ reasoning gate. But one E2B-distilled lesson came out backwards: "slightly
83
+ higher nozzle temp" to fight humid-PETG stringing, when you go lower. The JSON
84
+ was valid. The physics was wrong. Schema validation cannot catch that, which is
85
+ exactly why the human reads the lessons before they are trusted, and why
86
+ outcomes come from outside the model. Size buys you nuance. Plan for its
87
+ absence.
88
+
89
+ ## 7. Verify the real stack before you record, not while
90
+
91
+ `make preflight` grades eight gates on the actual model: env, latency (cold and
92
+ warm split), JSON contract, reasoning quality on a precedent-rich case and a
93
+ novel one, reflection, the Spine clamp, the app serving, the assets. Every fail
94
+ points at a written contingency. A previous project died integrating on the last
95
+ night. This one ran its dress rehearsal on day one of the endgame, and the
96
+ "novel case" gate caught what matters most: the model saying *"no close
97
+ precedent"* honestly instead of inventing one.
98
+
99
+ ## 8. Honesty is a feature you can ship, even when the numbers are bad
100
+
101
+ I checked the simulator against real FDM failure prints from a Modal ingestion
102
+ run. The first pass read 34.2 %. The cause was the data, not the model: the
103
+ parser only looked at G-code headers, so 178 of 260 rows had fan speed
104
+ defaulting to zero. After cleaning that — parse M106 across the whole file, final
105
+ temps, real retraction — the score settled at 32.6 % on 178 prints: correct on
106
+ every clean success, blind to the moderate failures. That gap is structural,
107
+ not a knob to turn, and forcing a prettier number would have broken the part
108
+ that works. So the constants stayed, the reason got written down, and the fix
109
+ got named. Calibration is also a data check. The same rule that keeps the model
110
+ from grading itself kept me from grading the simulator on bad data. Build the
111
+ system so the honest answer is also the impressive one.
112
+
113
+ ## 9. Tooling debt compounds faster on a deadline
114
+
115
+ Mid-endgame I adopted uv (locked env), reorganized a flat 20-file root into
116
+ `core/` and `scripts/`, and found that the `.env` file had never actually been
117
+ loaded by anything. None of it was the fun work. All of it was cheaper than
118
+ discovering it during the recording. Maintenance is the work.
119
+
120
+ ## 10. Distribution is part of the build
121
+
122
+ The fine-tune produced four GGUFs, but a GGUF on a Modal volume isn't a
123
+ shippable artifact — it's a binary blob with no chat template, no system
124
+ prompt, and no way for a stranger to try it. So I added the missing half of the
125
+ pipeline: the same Modal app that quantizes the model also uploads it to HF Hub
126
+ alongside `template`, `system`, and `params` files so `ollama run hf.co/…`
127
+ works out of the box, and a per-variant `ollama pull → ollama cp → ollama
128
+ push` step gets the same blobs listed on
129
+ [ollama.com/kylebrodeur](https://ollama.com/kylebrodeur) for the one-liner
130
+ case (`ollama run kylebrodeur/microfactory-node-v3-qat`). One adapter, three
131
+ derived artifacts (q4_k_m, q4_0, original LoRA), two registries, both with model
132
+ cards that link to each other. The QAT model got a q4_0 variant because that's
133
+ the quant it was trained for — highest fidelity for the QAT base — and the
134
+ `--as-name` flag I added to the upload step keeps the two quants from
135
+ overwriting each other on the Hub. Seven gotchas got written down on the way so
136
+ the next adapter is a ten-minute job, not a half-day. Done means someone you've
137
+ never met can pull and run it in one line. Build the publishing in.
138
+
139
+ ## 11. Capture interest without overpromising
140
+
141
+ To capture interest without pretending the product is finished, I added a simple
142
+ email signup at the bottom of the Space. It is opt-in only: checkbox + email,
143
+ clear privacy note, stored as a local JSONL and optionally synced to a private HF
144
+ dataset when `HF_TOKEN` is set. No print data, no uploaded files, no
145
+ third-party trackers. The same pattern as the field log, but for people instead
146
+ of jobs.
147
+
148
+ ---
149
+
150
+ **Project:** [node.microfactory.space](https://node.microfactory.space) ·
151
+ **Space:** [build-small-hackathon/microfactory-lab](https://huggingface.co/spaces/build-small-hackathon/microfactory-lab) ·
152
+ **Code:** [github.com/kylebrodeur/microfactory-lab](https://github.com/kylebrodeur/microfactory-lab) ·
153
+ **Ledger:** [kylebrodeur/chief-engineer-ledger](https://huggingface.co/datasets/kylebrodeur/chief-engineer-ledger)