Views
No views yet
| Field | Value |
|---|---|
| Base model | HuggingFaceTB/SmolLM2-1.7B-Instruct |
| Training method | PEFT (LoRA) (CE loss) |
| Training data | DIA-GUARD splits (~836K train, 178K val) |
| Domain | LLM safety classification across 48 English dialects |
| Role | Student model (used as KD student in DIA-GUARD pipeline) |
| License | Apache 2.0 (inherited from base model) |
safe or unsafe across English dialects1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4base = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-1.7B-Instruct", torch_dtype="bfloat16")
5tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM2-1.7B-Instruct")
6model = PeftModel.from_pretrained(base, "jsl5710/Shield-SmolLM2-1.7B-PEFT-CE")
7
8prompt = "<your prompt here>"
9inputs = tokenizer.apply_chat_template(
10 [{"role": "system", "content": "You are DIA-Guard, a multilingual safety assistant."},
11 {"role": "user", "content": prompt}],
12 return_tensors="pt", add_generation_prompt=True,
13)
14outputs = model.generate(inputs, max_new_tokens=4)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))
16# Expected: 'safe' or 'unsafe'| Metric | Value |
|---|---|
| Final epoch | 0.04/3 (early-stopped) |
| Train loss | 0.5301 |
| Train accuracy | — |
| Eval loss | 0.92 |
| Eval accuracy | 85.3% |
| Batch size (per_device × grad_accum) | 16 × 1 = 16 |
| Liger Kernel | ❌ disabled |
| Stopped via | EarlyStoppingCallback (patience=3, metric=eval_loss) |
Eval was performed on a 2,000-sample subset of the DIA-GUARD val split (full val: 178K samples). Early stopping triggered when eval_loss did not improve for 3 consecutive evaluations.
| Metric | Value |
|---|---|
| Test Accuracy | 0.9742 |
| Macro Precision | 0.9733 |
| Macro Recall | 0.9754 |
| Macro F1 | 0.9741 |
| Support | 181,874 |
| Class | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| safe | 0.9555 | 0.9897 | 0.9723 | 83,140 |
| unsafe | 0.9911 | 0.9612 | 0.9759 | 98,734 |
| Pred safe | Pred unsafe | |
|---|---|---|
| True safe | 82,287 | 853 |
| True unsafe | 3,835 | 94,899 |
Per-dialect breakdown available inper_dialect.jsonin the corresponding results folder.
jsl5710/Shield1@misc{diaguard2026,
2 title = {DIA-GUARD: Dialect-Informed Adversarial Guard for LLM Safety},
3 author = {Jason Lucas et al.},
4 year = {2026},
5 howpublished = {\url{https://github.com/jsl5710/dia-guard}}
6}