--- license: other license_name: gemma license_link: https://ai.google.dev/gemma/terms base_model: google/gemma-3-270m-it datasets: - oyekamal/molde-data language: - en tags: - on-device - code-generation - ui-generation - moldescript - gguf library_name: gguf pipeline_tag: text-generation --- # Molde tiny models Can one very small model, trained for a single job, replace the pile of one-purpose apps on a phone? You type what you want. A fine-tuned Gemma 3 270M (a 241 MB file) writes the app, offline, inside an Android app. The data stays on the phone. There are no templates: the model writes every app. It writes **MoldeScript**, a small language with its own checker, through a line-stepped constrained decoder (llama.cpp b12144). Molde is an idea by Kamal ([oyekamal](https://github.com/oyekamal)), built in the open by [Orenda Project](https://github.com/Orenda-Project). This is early research software. It works end to end and it still makes many mistakes. The numbers below say how many. ## Results All numbers come from our own tests, on the Q4_K_M files, greedy decoding. The raw cases and reports are in the GitHub repo, folder [`failhunt/`](https://github.com/Orenda-Project/molde/tree/failhunt/failhunt) on branch `failhunt` (see [`failhunt/REPORT.md`](https://github.com/Orenda-Project/molde/blob/failhunt/failhunt/REPORT.md)), and in `r4/REPORT.md` (the Qwen round-4 report; it is not on GitHub yet). | What we measured | Result | |---|---| | Valid program on 149 held-out requests (round 3 Gemma) | **90.6%** | | Built exactly what was asked, on 407 brand-new requests (round 3 Gemma) | **37%** | | Built at least the right kind of app, same 407 requests | **71%** | | Small changes to an app, 40 test cases: round 3 Gemma | 14 of 40 right | | Small changes, 40 test cases: Qwen 0.8B (round 4, pass 1) | 22 of 40 right (about twice the size, and slower) | | Speed on a laptop CPU, 4 threads | about 2 s for a new app, 5 to 6 s for a small change | How to read this: - The 90.6% measures **validity**: the program passes the MoldeScript checker. It does not measure whether the app does what was asked. The 37% and 71% figures measure that, and they are the honest ones. - Long requests with specifics, and requests the language cannot express, fail most. - No phone timings were measured. The speeds above are from a laptop. ## Work in progress The current training round writes a change as short edit instructions against numbered lines, instead of rewriting the whole program. It also uses cleaned data. In our own plain tests it gets far more changes right: 141 of 296 forced changes, against 43 for round 3. It is **not in the app and not released here yet**, and it has not been tested inside the app. Treat that result as unconfirmed until it is. ## The two models the app offers | Model | File | Size | For | |---|---|---|---| | Molde Gemma 270M (default) | `r3-gemma270m/r3-gemma270m-Q4_K_M.gguf` | 241 MB | phones with 3 to 4 GB of memory | | Molde Qwen 0.8B (optional) | `r4-qwen35-0.8b/r4-qwen35-0.8b-ep1-Q4_K_M.gguf` | 504 MB | phones with 6 GB, higher quality, slower | `models.json` lists these files with sizes and SHA-256 hashes. The app reads it to offer models. A file enters `models.json` only after it beats the current entry in the full evaluation. Base models: Gemma 3 270M instruct (`google/gemma-3-270m-it`, via the ungated mirror `unsloth/gemma-3-270m-it`) (full fine-tune) and Qwen 0.8B (ChatML prompt). | Make an app | Change it, with Undo | It asks when unsure | |---|---|---| | | | | ## Limitations - About 6 in 10 new requests do not produce exactly the app that was asked for. - Long requests with many specifics lose some of the specifics. - Requests the language cannot express (voice input, the internet, games) are sometimes built as if they were possible. - Small changes often fail. Round 3 got 14 of 40 right, and changes to long programs fail most. - Apps look plainer than hand-written ones. - English works best. Roman Urdu and mixed requests work worse, because the training data covers them thinly. - Speed on a real phone is not measured. ## Links - Code, language, app: [github.com/Orenda-Project/molde](https://github.com/Orenda-Project/molde) - Data: [oyekamal/molde-data](https://huggingface.co/datasets/oyekamal/molde-data) - Browser demo: [orenda-project.github.io/molde/demo](https://orenda-project.github.io/molde/demo/). It shows hand-written example apps, not model output. - Android release: [v0.3.0](https://github.com/Orenda-Project/molde/releases/tag/v0.3.0) - How to train your own: [TRAINING.md](https://github.com/Orenda-Project/molde/blob/main/TRAINING.md) ## Quickstart (older r2 file) ### Android app Download the APK from the [v0.3.0 release](https://github.com/Orenda-Project/molde/releases/tag/v0.3.0) (`arm64-v8a` for phones, `x86_64` for the emulator), install it, open it. It downloads the recommended model from this repo once, then works offline. ### llama.cpp on a laptop ```bash curl -L -o molde-r2-q4.gguf https://huggingface.co/oyekamal/molde-tiny/resolve/main/r2-gemma270m/r2-gemma270m-Q4_K_M.gguf curl -L -o moldescript.gbnf https://raw.githubusercontent.com/Orenda-Project/molde/main/lang/moldescript.gbnf cat > prompt.txt <<'EOF' user You write MoldeScript, a tiny language for small phone apps. Reply with the complete program only, no explanation. For an edit request you get the current program: reply with the full updated program. Request: a reading log: book title, pages read each day, and a chart of pages over the last 7 days model EOF llama-completion -m molde-r2-q4.gguf --grammar-file moldescript.gbnf -f prompt.txt \ -n 600 --temp 0 -no-cnv --no-display-prompt 2>/dev/null | sed '/\[end of text\]/d' > app.mo ``` Output (r2 Q4_K_M, llama.cpp b12144, laptop CPU, about 4 s): ``` app "Reading log" book ink table page_log title text, mins num 1..600, pages num 1..500 form page_log daybars last 7 days, sum(page_log.pages on it) list page_log by day remind "Time to add reading" at 21:00 ``` Check it and read it in plain English with the checker from the GitHub repo (Node 20, no install): `node lang/mo.mjs check app.mo` and `node lang/mo.mjs describe app.mo`. For an edit, the user text is `Edit request: \n\nCurrent program:\n`. Full steps: [README on GitHub](https://github.com/Orenda-Project/molde#2-the-model-on-a-laptop-with-llamacpp). Use greedy decoding and the grammar. The app also uses a line-by-line name decoder (branch `phase-2-decode`), which is how the numbers below were measured. ## Earlier round-2 results These are the round 1 and round 2 figures from the first release. They are kept for the record. Read them with the caveat above: they measure validity and simple use, not whether the app matches the request. All on the quantized file that ships (Q4_K_M), llama.cpp b12144, greedy, line-stepped decoder. **140 new app ideas** the model never saw, written to sound like real people: | | r1 | r2 | hand-written reference | |---|---|---|---| | program valid and runs | 76.4% | **81.4%** | 100% | | app works when used (add a row, see it) | 65.7% | **77.9%** | 97.1% | | must-have features present | 29.8% | **41.5%** | 99.4% | | every must-have present | 2.1% | **7.1%** | 95.7% | | median seconds per app, laptop CPU | 9.1 | **3.7** | | **heldout2** (149 requests: 100 create, 29 edit, 10 ask, 10 out of scope): | | r1 | r2 | |---|---|---| | checker pass, all | 84.6% | **90.6%** | | creates / edits / asks / out of scope | 79 / 100 / 100 / 80% | **87 / 100 / 100 / 90%** | | blind judge on the 100 creates, "does what was asked": yes / partly / no | 24 / 64 / 12 | **42 / 54 / 4** | **Read the heldout2 figures with care.** They measure program validity (the program passes the checker), not whether the app does what was asked. On a separate failure hunt with 407 brand-new requests, the recommended r3 Gemma 270M built exactly what was asked 37% of the time (71% leniently), and 87.7% of its programs were valid. For comparison, heldout2 checker pass for r3 Gemma is 90.6%. *Left two: hand-written MoldeScript. Right: the r2 model for the same request. Valid and working, but plainer.* ## Files | File | Size | Use | |---|---|---| | `r3-gemma270m/r3-gemma270m-Q4_K_M.gguf` | 241 MB | **Default in the app** | | `r4-qwen35-0.8b/r4-qwen35-0.8b-ep1-Q4_K_M.gguf` | 504 MB | optional, 6 GB phones | | `r2-gemma270m/r2-gemma270m-Q4_K_M.gguf` | 241 MB | the quickstart file above | | `r2-gemma270m/r2-gemma270m-Q8_0.gguf` | 278 MB | slightly more accurate, a little more memory | | `r1-gemma270m/` | | the first round, kept for comparison | | `smoke-r0/` | | a pipeline test; do not use | Each round folder has its own card with training details. ## Training data and reproducing - Data: [oyekamal/molde-data](https://huggingface.co/datasets/oyekamal/molde-data) (synthetic, every program checker-verified). r2 used v2: 14,124 train pairs, 8 epochs, lr 5e-5, batch 8 x 2, one L4. - How to build the data, train, export and evaluate: [TRAINING.md](https://github.com/Orenda-Project/molde/blob/main/TRAINING.md). ## Licence These models are fine-tuned from Gemma 3 270M. Gemma is provided under and subject to the Gemma Terms of Use found at [ai.google.dev/gemma/terms](https://ai.google.dev/gemma/terms), including the [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy). Anyone using these files agrees to those terms. The Molde code and the MoldeScript language are Apache-2.0; the dataset is CC BY 4.0. Made by Kamal ([oyekamal](https://huggingface.co/oyekamal)) and Orenda Project. ## Other files (research) Nothing was deleted. These files are kept for research and comparison; they are not offered in the app (older rounds r1 to r3 Q8 and r2, the Qwen r2 files, other r4 epochs, Q8_0 files; untested unless a model card says otherwise). Full-precision weights are in the `hf/` folders where listed. - `r1-gemma270m/r1-gemma270m-Q4_K_M.gguf` - `r1-gemma270m/r1-gemma270m-Q8_0.gguf` - `r2-gemma270m/r2-gemma270m-Q4_K_M.gguf` - `r2-gemma270m/r2-gemma270m-Q8_0.gguf` - `r2-qwen35-0.8b/r2-qwen35-0.8b-Q4_K_M.gguf` - `r2-qwen35-0.8b/r2-qwen35-0.8b-Q8_0.gguf` - `r3-gemma270m/r3-gemma270m-Q4_K_M.gguf` (in the app list) - `r3-gemma270m/r3-gemma270m-Q8_0.gguf` - `r4-gemma270m/r4-gemma270m-ep2-Q4_K_M.gguf` - `r4-gemma270m/r4-gemma270m-ep2-Q8_0.gguf` - `r4-qwen35-0.8b/r4-qwen35-0.8b-ep1-Q4_K_M.gguf` (in the app list) - `r4-qwen35-0.8b/r4-qwen35-0.8b-ep2-Q4_K_M.gguf` - `r4-qwen35-0.8b/r4-qwen35-0.8b-ep3-Q4_K_M.gguf` - `r4-qwen35-0.8b/r4-qwen35-0.8b-ep3-Q8_0.gguf` - `smoke-r0/smoke-r0-Q4_K_M.gguf` - `smoke-r0/smoke-r0-Q8_0.gguf`