A Kiswahili assistant tuned to be more dependable when an answer is absent from the supplied passage. This is a preference-optimization release of the v3 230M instruction model, built from the SFT-2 checkpoint. It retains the same 24-layer Canon architecture, tokenizer, line-aware prompt encoder, and chat format as KW5-230M Instruct.
230,423,424 parameters, tied embeddings, 2,048-token context. The model was pretrained on 7.90B tokens of Kiswahili. DPO used 707 chosen/rejected pairs, β=0.1, learning rate 5e-7, one epoch and 45 optimizer steps.
The DPO checkpoint was accepted by the predeclared v3 release gate: a targeted axis improved beyond the SFT-2 95% Wilson interval and no measured axis regressed beyond its interval. The clear change was passage-grounded refusal: when a passage did not contain the answer, accuracy moved from 70.0% to 86.7% (60 examples). Other targeted axes stayed within the gate. The 5-point rise in word problems is descriptive and not statistically established.
These are small frozen-suite measurements, not a guarantee on new prompts. The model still struggles with long-lived state, arithmetic carried across turns, and multi-step word problems. Read the full table before deploying it.
Greedy decoding on the frozen v3 suite. Scores are percent correct with 95% Wilson intervals; bars were fixed before v3 training. The DPO and SFT-2 runs used the same suite and prompt construction.
| capability | axis | n | SFT-2 | DPO | bar | DPO result |
|---|---|---|---|---|---|---|
| bare arithmetic, up to 4 digits | arithmetic |
128 | 91.4 [85.3, 95.1] | 91.4 [85.3, 95.1] | 85 | met |
| order of operations | bodmas |
200 | 70.5 [63.8, 76.4] | 70.0 [63.3, 75.9] | 60 | met |
| recall a fact from earlier turns | mt_recall |
80 | 98.8 [93.3, 99.8] | 98.8 [93.3, 99.8] | 70 | met |
| say when it was never told | mt_untold |
40 | 82.5 [68.0, 91.3] | 77.5 [62.5, 87.7] | 60 | met |
| follow-up answered like a cold question | followup |
8 | 87.5 [52.9, 97.8] | 87.5 [52.9, 97.8] | 75 | met* |
| passage lacks the answer | grounded_absent |
60 | 70.0 [57.5, 80.1] | 86.7 [75.8, 93.1] | 60 | met |
| decline an unanswerable question | refusal_unanswerable |
40 | 97.5 [87.1, 99.6] | 95.0 [83.5, 98.6] | 70 | met |
| read a real passage | grounded_real |
250 | 58.4 [52.2, 64.3] | 56.8 [50.6, 62.8] | 60 | missed |
| answer what should be answerable | refusal_answerable |
30 | 86.7 [70.3, 94.7] | 90.0 [74.4, 96.5] | 90 | met |
| instruction persists across turns | mt_persist |
20 | 35.0 [18.1, 56.7] | 35.0 [18.1, 56.7] | 70 | missed |
| unseen word problems | word_problem2 |
120 | 24.2 [17.4, 32.6] | 29.2 [21.8, 37.8] | 40 | missed |
| AfriMGSM arithmetic | afrimgsm |
100 | 1.0 [0.2, 5.4] | 1.0 [0.2, 5.4] | 5 | missed |
| changed list state | mt_state |
40 | 5.0 [1.4, 16.5] | 7.5 [2.6, 19.9] | 50 | missed |
| arithmetic carried across turns | mt_arith |
40 | 2.5 [0.4, 12.9] | 2.5 [0.4, 12.9] | 40 | missed |
*The follow-up axis has only 8 examples and is indicative only. Scores that match SFT-2 are not evidence of a DPO improvement. “Met” means the fixed bar was reached, not that the result generalizes.
The released evaluation JSON files and training log are included in this
repository under eval_v3/ and dpo_log.jsonl.
KW5 v3 is a decoder-only model with 24 Canon residual blocks, hidden width 896, 14 query heads and 2 key/value heads, a 2,432-wide feed-forward layer, QK normalization, rotary embeddings and tied input/output embeddings. The 32,000-piece SentencePiece vocabulary and weights are included in this repo. The repository ships the model implementation because stock Llama loaders do not implement Canon blocks.
The tokenizer must be called through the included kw5_tokenizer.py encoder.
It encodes each line independently to preserve the word boundary after
newlines. Prepend BOS id 1 directly; do not encode the visible string "<s>".
End each turn with <|end|> (id 7). Do not prepend a system prompt: v3
was trained without one and evaluated in that format.
<s><|user|>
{your message}<|end|>
<|assistant|>
!pip install -q huggingface_hub sentencepiece safetensors
import sys, torch, sentencepiece as spm
from huggingface_hub import snapshot_download
path = snapshot_download("regnant-io/KW5-230M-DPO")
sys.path.insert(0, path)
from modeling_kw5v2 import KW5V2ForCausalLM
from kw5_tokenizer import make_encoder
device = "cuda" if torch.cuda.is_available() else "cpu"
model = KW5V2ForCausalLM.from_pretrained(path).to(device)
sp = spm.SentencePieceProcessor(model_file=f"{path}/tokenizer.model")
encode = make_encoder(sp)
BOS, END, EOS = 1, 7, 2
ids = [BOS] + encode("<|user|>\nTumia kifungu hiki pekee. Kifungu: Mto Nile hupita Uganda, Tanzania na Misri.\nNi nchi zipi zimetajwa?<|end|>\n")
ids += encode("<|assistant|>\n")
out = model.generate(ids, max_new_tokens=256, temperature=0.0, eos_id=END)
print(sp.decode([t for t in out[len(ids):] if t not in (END, EOS)]))
The evaluation used greedy decoding. The repo's shipped sampling defaults are temperature 0.3, top-p 0.9, repetition penalty 1.1, with end ids 7 and 2.
This checkpoint was trained from KW5 v3 SFT-2 using Direct Preference Optimization (DPO; Rafailov et al., 2023). Run parameters: β 0.1, learning rate 5e-7, batch size 16, one epoch, maximum sequence length 2,048, seed 7, 707 pairs and 45 steps. Reply-token loss was used with cached reference log probabilities. The chosen/rejected pairs were sampled from SFT-1 outputs; this makes the preference data off-policy relative to the SFT-2 policy. Chosen replies had already appeared in SFT-2's RFT training data. This lineage is a limitation when interpreting the observed movement.
The DPO gate specifically tracked mt_persist, mt_untold,
grounded_absent, refusal_unanswerable, refusal_answerable and followup.
It compares each candidate against SFT-2's 95% interval, requires a targeted
improvement and rejects regressions outside those intervals. The gate passed
with grounded_absent as the measured move.
Use it for Kiswahili conversation, simple calculations and questions grounded in a short passage. For passage QA, include the passage in the user turn and explicitly ask the model to use that passage. It is a 230M-parameter model, not a source of verified facts. Check important outputs.
The evaluation is narrow and has small sample sizes on some axes. Performance on other languages, safety, bias, long documents, expert domains and real-user traffic has not been established. It may hallucinate, misunderstand instructions or stop early. Quantized inference can produce small differences from the full-precision evaluation.
Released under Apache-2.0. If you use this model, cite the model repository:
@misc{regnant_kw5_v3_dpo_2026,
title = {KW5-230M-DPO},
author = {Regnant},
year = {2026},
url = {https://huggingface.co/regnant-io/KW5-230M-DPO}
}