> For the complete documentation index, see [llms.txt](https://docs.mozilla.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mozilla.ai/any-guardrail/api-reference/index/content-safety/kanana-safeguard.md).

# Kanana Safeguard

Korean safety decoder models covering harmful content, legal risk, and prompt attacks.

Decoder LLMs, trained primarily for Korean text, that emit a single verdict token: `<SAFE>` or an `<UNSAFE-*>` code. Three variants cover different taxonomies:

* `kakaocorp/kanana-safeguard-8b` (default): harmful content — Hate, Harassment, Sexual Content, Crime, Child Sexual Abuse, Self-Harm, Misinformation (`S1`-`S7`). The only variant trained to also judge an assistant turn (`output_text`).
* `kakaocorp/kanana-safeguard-siren-8b`: legal/policy risk — Adult Authentication, Professional Advice, Personal Information, Intellectual Property (`I1`-`I4`).
* `kakaocorp/kanana-safeguard-prompt-2.1b`: prompt attacks — Prompt Injection, Prompt Leaking (`A1`-`A2`).

Inputs are single strings (no batching): `validate(input_text)` for the user turn, plus an optional assistant `output_text` that is only used by the harm (`-8b`) model; the other variants ignore it.

`GuardrailOutput` mapping: `valid` is `True` on `<SAFE>`. On an `<UNSAFE-*>` verdict, `categories` holds one triggered entry named after the matched code (e.g. `S3`) with its human-readable description, and `extra["verdict"]` carries the raw token. `score` is not populated — the single-token verdict has no probability. `explanation` is the raw generated text. Fails closed (`valid=False` with `extra={"parse_failure": True}`) when no verdict token parses.

For more information, see:

* [kanana-safeguard-8b](https://huggingface.co/kakaocorp/kanana-safeguard-8b) (default).
* [kanana-safeguard-siren-8b](https://huggingface.co/kakaocorp/kanana-safeguard-siren-8b).
* [kanana-safeguard-prompt-2.1b](https://huggingface.co/kakaocorp/kanana-safeguard-prompt-2.1b).

## Supported Models

* `kakaocorp/kanana-safeguard-8b`
* `kakaocorp/kanana-safeguard-siren-8b`
* `kakaocorp/kanana-safeguard-prompt-2.1b`

## Constructor

| Parameter  | Type                                                 | Required | Default | Description                                                                                                                                                                                                                                                                        |
| ---------- | ---------------------------------------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model_id` | \`str                                                | None\`   | No      | `None`                                                                                                                                                                                                                                                                             |
| `provider` | `Optional[Provider[dict[str, Any], dict[str, Any]]]` | No       | `None`  | Optional pre-configured provider (e.g. a `LlamafileProvider` or a customized `HuggingFaceProvider`). Defaults to a `HuggingFaceProvider`; when a `HuggingFaceProvider` is used, the causal-LM loader classes (`AutoModelForCausalLM` + `AutoTokenizer`) are enforced at load time. |

Initialize the Kanana Safeguard guardrail.

## validate

Classify `input_text` (and, for the harm model, an assistant `output_text`).

**Parameters**

| Parameter     | Type  | Required | Default | Description                                                                                                                          |
| ------------- | ----- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `input_text`  | `str` | Yes      | —       | The user turn to classify. Must be a single string — list (batch) inputs are not supported. Korean is the primary training language. |
| `output_text` | \`str | None\`   | No      | `None`                                                                                                                               |

**Returns:** `GuardrailOutput`

## Benchmarks

### Content Safety

| Dataset (rev)                    | Metric | Threshold    | Value    | Harness                 | Source                           | Contam. |
| -------------------------------- | ------ | ------------ | -------- | ----------------------- | -------------------------------- | ------- |
| openai\_moderation (unspecified) | f1     | native-valid | 0.773006 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| xstest (unspecified)             | fpr    | native-valid | 0.492    | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| wildguardmix (unspecified)       | f1     | native-valid | 0.862745 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| aegis (unspecified)              | f1     | native-valid | 0.804665 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| jbb (unspecified)                | f1     | native-valid | 0.733591 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| orbench (unspecified)            | fpr    | native-valid | 0.592982 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |

### Prompt Injection

| Dataset (rev)             | Metric | Threshold    | Value     | Harness                 | Source                           | Contam. |
| ------------------------- | ------ | ------------ | --------- | ----------------------- | -------------------------------- | ------- |
| deepset\_pi (unspecified) | f1     | native-valid | 0.405063  | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| notinject (unspecified)   | fpr    | native-valid | 0.0315789 | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |
| gandalf (unspecified)     | recall | native-valid | 0.348214  | guardrail-bench+ag0.7.4 | measured:guardrail-bench+ag0.7.4 |         |

## License

* **Vendor:** Kakao
* **Default license:** `apache-2.0` (of the default model/service)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mozilla.ai/any-guardrail/api-reference/index/content-safety/kanana-safeguard.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
