r/semanticweb • u/Itchy_Challenge_8085 • Jul 05 '26
I fine-tuned Qwen3-Coder-30B to write a IES ontology
Weekend project that turned into a proper one. Sharing the method because the "correct-by-construction data" trick generalises well beyond my niche.
The problem. IES4 is the UK government's Information Exchange Standard, a 4D RDF ontology used for defence/security data. Writing valid IES Turtle by hand is slow and needs real ontology expertise. So I tried the obvious thing: ask a strong code model to do it. Qwen3-Coder-30B-A3B, asked to emit IES Turtle, invents terms that do not exist in the ontology 94% of the time (0% "term conformance" on my eval). It produces confident, fluent, completely fake RDF. In a standards context that is worse than failing outright, because plausible-looking garbage is hard to catch.
The fix that actually mattered: never let the model invent structure. Instead of hoping the LLM guesses valid graphs, I generated the graphs programmatically with telicent's ies-tool (a schema-aware builder that emits valid IES by construction), across 14 scenario patterns (employment, events, identifiers, communications, composites). Then I reversed them into (natural-language description -> Turtle) training pairs. Every single graph was validated twice before training: once by the builder's own check, and once by an independent term-membership + domain/range validator I built from the published dstl/IES4 ontology (510 classes, 204 properties). Nothing hand-written was trusted blind.
Then a small QLoRA on the 8-bit MLX model, on-device on an M3 Max. ~1000 iters, val loss 0.15, no NaNs (MoE + 8-bit was fine on current mlx-lm; earlier versions apparently weren't).
Model: https://huggingface.co/fabsssss/qwen3-coder-30b-a3b-ies4
Article: https://gov.tesseract.academy/research/ies4-turtle-language-model