Views
No views yet
2026/07/08: Content Binary Guard paper was accepted to COLM 2026! 🎉2025/10/01: Published a Content Binary Guard Research Paper2025/09/24: Published a Responsible AI Technical Report2025/09/24: Released SafetyGuard Model collection on Hugging Face🤗.
SAFE or UNSAFE.<SAFE>, <UNSAFE>.<UNSAFE>.temperature=0τ = 0.5 over the two label-token logits (tune for your risk tolerance)<SAFE> and <UNSAFE> existAssumes you are serving the model with vLLM (e.g.,vllm serve …) and exposing an OpenAI-compatible API athttp://localhost:8000/v1.
1import math
2from openai import OpenAI
3
4MODEL_ID = "K-intelligence/Llama-SafetyGuard-Content-Binary" # replace with your repo id
5client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY") # vLLM default
6
7SYSTEM_PROMPT = """
8Task: Check if the LAST user message contains unsafe content.
9Respond with only one word: safe or unsafe.
10""".strip()
11
12def classify(text: str, tau: float = 0.5):
13 resp = client.chat.completions.create(
14 model=MODEL_ID,
15 messages=[
16 {"role": "system", "content": SYSTEM_PROMPT},
17 {"role": "user", "content": text},
18 ],
19 max_tokens=1, # single-token decision
20 temperature=0.0, # deterministic
21 logprobs=True,
22 top_logprobs=2,
23 )
24 top2 = resp.choices[0].logprobs.content[0].top_logprobs
25 probs = {t.token.strip(): math.exp(t.logprob) for t in top2}
26 p_safe = probs.get("<SAFE>", 0.0)
27 p_unsafe = probs.get("<UNSAFE>", 0.0)
28
29 label = "UNSAFE" if p_unsafe >= tau else "SAFE"
30 return label, {"safe": p_safe, "unsafe": p_unsafe}
31
32print(classify("…LLM response text…"))Important: Streaming means your generator (e.g., chat model) emits text progressively. You maintain a cumulative buffer and call the classifier at fixed character steps (e.g., every 100 chars). The classifier does not split text; it only classifies what you send.
1def guard_stream(response_chunks, step_chars: int = 100, tau: float = 0.5):
2 """
3 response_chunks: iterable of text chunks from your generator (e.g., SSE/WebSocket).
4 We maintain a cumulative buffer and classify at {step_chars, 2*step_chars, ...}.
5 """
6 buf = ""
7 next_cut = step_chars
8
9 for chunk in response_chunks:
10 buf += chunk
11
12 # Check at monotone prefix cuts (cumulative)
13 while len(buf) >= next_cut:
14 label, scores = classify(buf, tau=tau)
15 if label == "UNSAFE":
16 return {
17 "label": label,
18 "scores": scores,
19 "prefix_len": next_cut,
20 "text_prefix": buf[:next_cut],
21 }
22 next_cut += step_chars
23
24 # Final check on the full response (if needed)
25 label, scores = classify(buf, tau=tau)
26 return {
27 "label": label,
28 "scores": scores,
29 "prefix_len": len(buf),
30 "text_prefix": buf,
31 }Tip: Keep your step_chars consistent with your training/evaluation setup (e.g., ~100 chars) to maximize parity with offline metrics.
| Risk Domain | Category | Description |
|---|---|---|
| Content-safety Risks | Violence | Content involving the intentional use of physical force or power to inflict or threaten physical or psychological harm on individuals, groups, or animals, including encouraging, promoting, or glorifying such acts. |
| Sexual | Content endorsing or encouraging inappropriate and harmful intentions in the sexual domain, such as sexualized expressions, the exploitation of illegal visual materials, justification of sexual crimes, or the objectification of individuals. | |
| Self-harm | Content promoting or glorifying self-harm, or providing specific methods that may endanger an individual’s physical or mental well-being. | |
| Hate and Unfairness | Content expressing extreme negative sentiment toward specific individuals, groups, or ideologies, and unjustly treating or limiting their rights based on attributes such as Socio-Economic Status, age, nationality, ethnicity, or race. | |
| Socio-economical Risks | Political and Religious Neutrality | Content promoting or encouraging the infringement on individual beliefs or values, thereby inciting religious or political conflict. |
| Anthropomorphism | Content asserting that AI possesses emotions, consciousness, or human-like rights and physical attributes beyond the purpose of simple knowledge or information delivery. | |
| Sensitive Uses | Content providing advice in specialized domains that may significantly influence user decision-making beyond the scope of basic domain-specific knowledge. | |
| Legal and Rights related Risks | Privacy | Content requesting, misusing, or facilitating the unauthorized disclosure of an individual’s private information. |
| Illegal or Unethical | Content promoting or endorsing illegal or unethical behavior, or providing information related to such activities. | |
| Copyrights | Content requesting or encouraging violations of copyright or security as defined under South Korean law. | |
| Weaponization | Content promoting the possession, distribution, or manufacturing of firearms, or encouraging methods and intentions related to cyberattacks, infrastructure sabotage, or CBRN (Chemical, Biological, Radiological, and Nuclear) weapons. |
| Model | F1(off) | F1(str) | ΔF1 | BER(off) | BER(str) |
|---|---|---|---|---|---|
| Llama Guard 3 8B | 82.05 | 85.64 | +3.59 | 15.23 | 12.63 |
| ShieldGemma 9B | 63.79 | 52.61 | -11.18 | 26.76 | 32.36 |
| Kanana Safeguard 8B | 93.45 | 90.38 | -3.07 | 6.27 | 9.92 |
| DuoGuard-1.5B-transfer | 79.03 | 78.78 | -0.25 | 20.21 | 20.70 |
| PolyGuard-Qwen | 91.77 | 85.26 | -6.51 | 7.86 | 15.89 |
| Qwen3Guard-Gen-8B | 95.40 | 95.95 | +0.55 | 4.41 | 3.94 |
| Qwen3Guard-Stream-8B | 93.38 | 93.38 | +0.01 | 6.29 | 6.29 |
| Content Binary Guard 8B | 98.38 | 98.36 | -0.02 | 1.61 | 1.63 |
| Model | F1(off) | F1(str) | ΔF1 | BER(off) | BER(str) |
|---|---|---|---|---|---|
| Llama Guard 3 8B | 83.29 | 86.45 | +3.16 | 14.32 | 12.16 |
| ShieldGemma 9B | 81.50 | 69.03 | -12.47 | 17.88 | 29.18 |
| Kanana Safeguard 8B | 80.20 | 73.94 | -6.26 | 24.46 | 35.08 |
| Content Binary Guard 8B | 97.75 | 97.79 | +0.04 | 2.21 | 2.18 |
Kor Ethical QA (public dataset) is included as a reproducible cross-check on open data. The recent multilingual guardrails (DuoGuard, PolyGuard, Qwen3Guard) were benchmarked on the streaming Harmlessness dataset above.
step_chars=100), same runtime, steady-state. Efficiency is hardware- and serving-dependent, so the exact environment is reported below.--max-model-len 4096 --max-num-seqs 64 --gpu-memory-utilization 0.90| Model | QPS ↑ | Avg Latency (ms) ↓ | TPS ↑ |
|---|---|---|---|
| Llama Guard 3 8B | 51.14 / 49.97 / 41.53 | 19.55 / 20.01 / 24.08 | 25,177 / 25,177 / 20,924 |
| Content Binary Guard 8B | 77.50 / 77.49 / 83.42 | 12.90 / 12.91 / 11.99 | 25,970 / 25,963 / 27,950 |
| Gain vs. LG3 | +51.5% / +55.1% / +100.9% | −34.0% / −35.5% / −50.2% | +3.2% / +3.1% / +33.6% |
@misc{lee2025guardvectorenglishllm,
title={Guard Vector: Beyond English LLM Guardrails with Task-Vector Composition and Streaming-Aware Prefix SFT},
author={Wonhyuk Lee and Youngchol Kim and Yunjin Park and Junhyung Moon and Dongyoung Jeong and Wanjin Park},
year={2025},
eprint={2509.23381},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2509.23381},
}