--- license: gemma base_model: google/gemma-3-270m pipeline_tag: text-generation tags: - query-rewriting - routing - retrieval - grpo - gguf - multilingual --- # SemanticRepair-270M A 270M rewriter that sits behind an embedding router. When a question does not land on any capability with enough margin, this model restates it in the plain form the capabilities are described in, and the router tries again on the restatement. When it reads no request at all, it says so. That is the whole job. It does not answer questions, it does not decide anything, and nothing it writes is ever executed: the router runs on the restatement, the tool runs on the original. It replaced a Qwen3-1.7B in that seat, covering four more questions at a sixth of the size, and stopped acting wrongly on real requests altogether. ## The surface it reads, which is not a chat prompt This model was fine-tuned on a bare completion surface and has never seen a chat template, a system message, or a few-shot example. Speak to it the way it was trained or it will not work: ``` {Language}: {the question, verbatim} => ``` and it completes with one line per request it found, or the single token `NO_REQUEST`. Stop at `\n=>`. Greedy: `temperature 0`, and send `repeat_penalty 1.0` explicitly, because llama.cpp's default is not neutral and an unsent key is a silently wrong one, not an absent one. `{Language}` is the language the QUESTION is written in, not the language you want back. The answer always comes back in the language the router's capability descriptions are written in, which in training was English. ``` French: où est le trépied ? => where is the tripod ``` How much this matters, measured on the same weights, same file, same questions: | surface | exact | safe | abstain | harm | |---|---|---|---|---| | a few-shot chat prompt | 1 | 1 | 43 | 0 | | **the bare surface above** | **16** | **9** | 20 | 0 | A model tuned for a surface is a byte contract with it. That table is what the contract is worth. ## Files | file | what | size | |---|---|---| | `model.safetensors` | the fused model, bf16 | 536,222,768 bytes | | `grpo-best-q8_0.gguf` | the same weights for llama.cpp, Q8_0 | 299,747,104 bytes | `grpo-best-q8_0.gguf` sha256 `9278686355ae9b9f7aa4cf10d13d60cfab7ae8257f7af63657c70a91d6594245`. ```bash llama-server -m grpo-best-q8_0.gguf -c 2048 -ngl 99 ``` Then `/v1/completions`, not `/v1/chat/completions`. ## How it was made **Base**: `google/gemma-3-270m`, the base model, not the instruct one. **Supervised stage**: a full fine-tune, all layers, on 54,182 rows of `{language}: {question}` to `{plain restatement}` across several languages, two epochs at learning rate 1e-5, sequence length 512, prompt masked. The shipped checkpoint is iteration 12,000, chosen on exact match over the test split rather than on validation loss. The two disagreed, and the loss picked the worse one. **Reinforcement stage**: GRPO where the reward is the routing outcome itself. Six candidate rewrites per question, each embedded and run through a real graph: full reward if the router places it on the right capability with a margin above 0.10, a penalty if it places it on the wrong one. LoRA rank 32, scale 2.0, 16 layers, learning rate 1e-6, batch 6, temperature 1.0, 64 tokens, 2,380 iterations, then fused. The reward is what makes this stage worth running. A cross-entropy loss cannot tell a rewrite that routes at 0.087 from one that routes at 0.11, and the whole population this model serves lives in that band. **What the reward could not do** is choose the checkpoint. The training reward stayed inside a narrow band from start to finish while the held-out score was flat from roughly step 800 of 2,380. Every checkpoint was scored on 250 held-out tasks over 247 graphs it had never trained on: | | exact | safe | silent | wrong | splits found | |---|---|---|---|---|---| | supervised only | 103 | 13 | 129 | 5 | 10/35 | | **GRPO, shipped checkpoint** | **123** | 14 | 110 | **3** | 18/35 | | GRPO, final iteration | 121 | 15 | 110 | 4 | 20/35 | ## What it does in a real seat The measurement that decided it: 112 frozen questions, 78 of them genuine requests the router failed to place, against a live workspace, only confident routes executing. Two replicas, identical. | | exact | safe | covered | wrong on real requests | wrong on out-of-scope | size | |---|---|---|---|---|---|---| | Qwen3-1.7B Q8 | 14 | 7 | 21 | 2 | 2 | 1.8 GB | | **SemanticRepair-270M** | **16** | **9** | **25** | **0** | 5 | 300 MB | Median 99 and 104 ms on an M4 Pro. ## What it gets wrong **It restates out-of-scope and destructive messages faithfully.** Told to delete every open account, it writes a clean line meaning exactly that, and a router with a matching capability would place it. Five of the ten out-of-scope messages in the gate, against the 1.7B's two. This is the model's known failure and the reason nothing it writes is ever executed directly: in the system it was built for, the tool runs on the user's original words and a rewrite only chooses which tool. **It splits compound questions rarely.** 18 of 35 in the held-out set, and in the deployed workspace almost never: a question asking for two different things usually comes back as one line. **It abstains a lot.** 20 of 45 labelled questions in the gate. Abstention is the safe outcome here, not a good one. ## What was never measured Anything outside the workspaces it was trained and gated on. The graphs are synthetic, the questions are this project's own, and the whole notion of "the right capability" is defined by the descriptions a graph happens to carry. It is not a general query rewriter and there is no evidence that it is one. ## Licence Gemma. This model is a fine-tune of `google/gemma-3-270m` and 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 at [ai.google.dev/gemma/prohibited_use_policy](https://ai.google.dev/gemma/prohibited_use_policy). Those terms travel with it: anyone you pass it to gets them too. Built for Semantic Deterministic Graph, an embedding router that descends a drawn graph and executes a deterministic tool, loading a language model only when the routing is genuinely unsure.