What it was trained to do
Two kinds of prompts, exactly as the agent builds them, each answered in the prompt's language:
- Report writer — input: detection facts (types, counts, confidence, positions), verified knowledge (causes / actions) and up to 2 retrieved
web-document passages; output: a JSON object
{summary, defects[], cause_text, action_immediate, action_prevent}.
- Grounded Q&A — questions about causes, corrective actions, what to check, why a verdict was given; plus refusals (it cannot change a
verdict; it does not know information that is not in the context). A retrieved passage is cited (
[S1]) only when it really supports the sentence.
It is not a general chat model and is not meant to replace the detector: the agent's rules, not the LLM, decide normal / suspected / abnormal.
Training
Table | |
|---|
| Method | QLoRA — 4-bit NF4 (double quant), bf16 compute; loss on the answer tokens only |
| LoRA | r = 16, alpha = 32, dropout 0.05, all attention and MLP projections (q, k, v, o, gate, up, down) — 43.6 M parameters, stored in fp32 |
| Data | 1,809 synthetic samples (1,836 generated, 27 longer than 2,560 tokens dropped): report and Q&A, ko / vi / en, PCB / metal / phone domains |
| Optimisation | 2 epochs, 228 optimizer steps (batch 1 × 16 accumulation), lr 1e-4 cosine, 5 % warm-up, paged AdamW 8-bit |
| Hardware / time | one RTX 3060 12 GB (about 8.8 GB used), 4 h 56 min |
The gold answers are not model-written: they are assembled from the detection facts, a reviewed ko / vi / en knowledge base and short knowledge
cards distilled from web documents (Wikipedia CC BY-SA and paraphrased technical pages, each with its source), using hand-written templates.
So the answers cannot invent causes or numbers, but their style is formulaic.
Known limitations
- Not evaluated yet (see the status above); the training loss was not logged.
- The Vietnamese and English knowledge translations were written for this project and have not been reviewed by native industry experts.
- Trained only on the agent's own prompt format and three domains; behaviour elsewhere is untested.
- Synthetic, template-style training data: expect repetitive phrasing.
Usage
import torchfrom peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizer base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-8B", torch_dtype=torch.bfloat16, device_map="auto")model = PeftModel.from_pretrained(base, "NonomiyaIzumi/qwen3-8b-defect-agent-lora")tok = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B")# build the prompt with the project's agent.writer.build_prompt(...) and call tok.apply_chat_template(..., enable_thinking=False)
To serve it with Ollama: merge the adapter into the base weights, convert to GGUF with llama.cpp and ollama create
(tools/llm_ft/merge.py and deploy_ollama.sh in the GitHub repository do exactly this).
License
The adapter follows the base model's Apache-2.0 license. Training texts were synthesised from project knowledge and paraphrased facts from
public web pages (sources are recorded in the GitHub repository under knowledge/rag/).