Views
No views yet
microsoft/Phi-3-mini-4k-instruct, fine-tuned for South African POPIA compliance Q&A. Given a compliance scenario or a question about POPIA, the adapted model answers in a consistent template grounded in actual POPIA Act section text.nli-popia-v2 (clause-level NLI judge) and sa-compliance-embeddings-v1 (POPIA retrieval).microsoft/Phi-3-mini-4k-instruct (3.8B params, MIT license)qkv_proj, o_proj, gate_up_proj, down_proj — 25.2M trainable params (0.65% of base)bf16 compute dtypepaged_adamw_8bit, lr 2e-4, cosine schedule, 5% warmup, weight decay 0scripts/train_popia_instruct.py.
Dataset builder: scripts/build_popia_instruct_dataset.py. Every instruction-response pair traces deterministically to a POPIA section text or a labelled scenario — no LLM-generated content in the training set.1from peft import PeftModel
2from transformers import AutoTokenizer, AutoModelForCausalLM
3import torch
4
5base_id = "microsoft/Phi-3-mini-4k-instruct"
6adapter_id = "labrat-aiko/popia-instruct-v0"
7
8tokenizer = AutoTokenizer.from_pretrained(base_id)
9base = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=torch.bfloat16, device_map="auto")
10model = PeftModel.from_pretrained(base, adapter_id)
11model.eval()
12
13messages = [
14 {"role": "system", "content": "You are a careful South African data-protection assistant. Answer in clear, professional English with reference to the Protection of Personal Information Act, 2013 (POPIA). When citing sections, use the form 'POPIA §X'."},
15 {"role": "user", "content": "What POPIA rule is implicated by this scenario? Our after-school maths app lets any 9-year-old sign up with just an email address."},
16]
17prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
18inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
19out = model.generate(**inputs, max_new_tokens=200, do_sample=False)
20print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))User: What POPIA rule is implicated by this scenario? Sign-up for our homework helper happens on the child's own phone with no parent in the loop. Gold: This scenario implicates POPIA §34 and POPIA §35 — the children's information provisions. Pred: This scenario implicates POPIA §34 and POPIA §35 — the children's information provisions.
User: Which POPIA sections govern data subject rights? Gold: The data subject rights concern is anchored in POPIA §5, §23, §24, §25. Pred: The data subject rights concern is anchored in POPIA §5 and POPIA §23.
User: What POPIA rule is implicated by this scenario? NUMSA's member-services team uses the union's own membership records to administer benefits. Gold: This scenario implicates POPIA §26 and POPIA §27 — the special personal information provisions. Pred: This scenario implicates POPIA §10 and POPIA §13 — the special personal information provisions.
nli-popia-v2, this model is a research / decision-support tool, not a substitute for a compliance review.semantix-ai repository.1@misc{eland2026popiainstruct,
2 author = {Eland, Akhona},
3 title = {popia-instruct-v0: A {QLoRA}-Fine-Tuned Phi-3-mini Adapter for South African Data Protection Q\&A},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/labrat-aiko/popia-instruct-v0}
7}labrat-aiko/nli-popia-v2 — clause-level NLI judge over the same 10 POPIA clauses (verification, not generation)labrat-aiko/sa-compliance-embeddings-v1 — POPIA retrieval embedding modelsemantix-ai — Python library that uses the judge in production