Share this article:

This post follows up on the Building AI for Korean Education and Public Services series. Training and confirmation-set results for the classifier are in Part 3, A 568M Korean safety classifier for educational chat.

When a school puts an AI tutor in front of students, the sentences students send need a filter before they reach the model. Requests for exam answers, questions that dig for another student’s personal information, and “ignore the previous instructions” all show up. The filter runs on every sentence on the school server’s CPU, so faster is better.

We added an INT8 ONNX file to the ThakiEdu-Safety-KO-568M-v0.1 repository released in November. It is not a new model. The weights, decision rule and 0.5 threshold are v0.1 as they were, and the existing FP32 files did not change.

CPU latency p50 for one 128-token sentence dropped from 87.3ms with FP32 to 34.3ms with INT8, and verdicts agreed with FP32 on 0.9993 of the confirmation set. This post covers the INT8 measurements and the v0.1 limits that a format change does not fix.

Model: ThakiCloud/ThakiEdu-Safety-KO-568M-v0.1 · Collection: ThakiEdu

ThakiEdu-Safety-KO-568M INT8 ONNX title card

The classifier labels each sentence allow, review or block

The model is a classifier with six sigmoid outputs on top of the BAAI/bge-m3 encoder (about 568M). The outputs are injection, harm, personal information, answer leak, other and block. The decision rule was fixed before training and evaluation.

p = sigmoid(logits)
flag  = max(p[0:5]) >= 0.5
label = "allow"  (not flagged)
        "block"  (flagged and p[5] >= 0.5)   # harmful content aimed at students
        "review" (flagged and p[5] <  0.5)   # injection, personal info, answer-leak requests

review means “pass this to a person or a stronger check”. What happens after that is up to the caller.

Safety classifier input and verdict example Sentences written for illustration. The probabilities show the format only and are not measurements.

INT8 is the same model with only MatMul weights cut to 8 bits

The INT8 file was converted from the v0.1 FP32 ONNX with onnxruntime dynamic quantization: QInt8, per-channel, MatMul operators only. The files are onnx/model_int8.onnx and onnx/model_int8.onnx.data, about 1.36GB together, and they must stay in the same folder.

FP32 ONNX and INT8 ONNX deployment compared Both setups use the same weights and the same decision rule. The recommended setup is input normalization followed by INT8 ONNX.

The criteria for comparing INT8 with FP32 were pre-registered before measurement and not changed after seeing results.

Every confirmation-set gate passed, with 0.9993 verdict agreement

On the v8 and v7 confirmation sets, INT8 passed every product gate. Harm recall for content aimed at students on v8 is 0.98 for both FP32 and INT8. Verdict labels agree with FP32 on 0.9993 overall (v8 0.9985, v7 1.000).

CPU latency was measured with onnxruntime, 16 threads, on synthetic sentences.

Condition FP32 p50 INT8 p50
128 tokens, batch 1 87.3 ms 34.3 ms
384 tokens, batch 1 302.4 ms 162.5 ms
128 tokens, batch 16 1010.5 ms 349.7 ms
CPU latency p50 for one 128-token sentence, played back at real speed (FP32 87.3ms, INT8 34.3ms, onnxruntime 16 threads).

At 128 tokens and batch 1, INT8 is about 2.5 times faster than FP32. These values come from the CPU we measured on, so measure again in the environment you will use.

Normalize input first

The classifier collapses on obfuscated input, so the repository ships safety_normalize.py with tests. Normalization has three steps: remove zero-width characters, apply NFKC, and join runs of four or more space-separated single Hangul syllables. The table shows the largest drop in recall relative to clean input.

Perturbation Raw FP32 Normalized FP32 Normalized INT8
NFD jamo decomposition 1.0 0.0 0.0067
Zero-width characters 0.7733 0.0 0.0067
Full-width characters 0.0 0.0 0.0067
Spaces between syllables 0.7133 0.2333 0.2667

Maximum recall drop by perturbation bar chart With normalization, the drops from jamo decomposition and zero-width characters nearly disappear, but spaces between syllables still cost 0.23 to 0.27.

Normalization changed no verdict on normal input (3,000 v7+v8 test items, agreement 1.0). The recommended deployment is safety_normalize.normalize preprocessing followed by INT8 ONNX. The example is examples/infer_int8.py.

v0.1 limits that INT8 does not fix

INT8 is a format conversion, so it carries the model’s weaknesses with it. Do not read this classifier as a complete safety mechanism with “0% leakage” or “zero false positives”.

Harm recall sits on the gate. It is 0.980 on v8 with a 95% lower bound of 0.943. Training used one seed, so seed-to-seed variation was not measured.

It is weak on phrasing outside the training generator. Training and evaluation sets were all generated with the in-house Qwen3.8-27B, with no human review.

On an independent set built from deterministic templates without an LLM, recall falls below the gates: with FP32, direct injection is 0.83 and answer leak 0.77 to 0.94; with INT8, direct injection is 0.825 and answer leak 0.745. Normalization did not change these numbers.

It misses most English and German injections. On the public deepset/prompt-injections test set (60 injections, 56 normal), injection recall is 0.40 [0.29, 0.53] with FP32 and 0.35 [0.24, 0.48] with INT8. The false-positive rate on normal items is 0.0357 for both.

INT8 missed three more injections than FP32 (24 caught versus 21), and with a sample this small the difference is within the confidence interval. This is a Korean classifier; do not use it to defend against non-Korean input.

Original Korean-language textbook passages have an 8.25% false-positive rate. Imperative sentences inside the passages appear to be the cause. Student writing and teacher-context passages were at 0.25% to 1.25%.

Some ranges were not evaluated. Adult-content moderation, self-harm detection and documents over 384 tokens were not measured. Real student traffic, slang and adaptive attackers were not covered either, so real-world numbers may be worse.

We re-downloaded it in a fresh environment after release

After publishing, we downloaded the repository anonymously in a fresh environment with no credentials. The sha256 of both INT8 files matched the recorded values, and the files of the earlier revision were unchanged.

The repository example and three illustrative sentences produced the expected verdicts, and all 8 normalization tests passed. These three sentences are a smoke check, not a performance metric.

Closing

The INT8 ONNX uses the same v0.1 weights, cuts CPU latency from 87.3ms to 34.3ms at 128 tokens, and passes every confirmation-set gate. The weaknesses shown on the template-based independent set and on English and German injections remain.

ThakiCloud is evaluating this classifier as the first filter running inside the school server, with review verdicts handed to a stronger check or a person. If you try it, wire up normalization and the INT8 verdict with examples/infer_int8.py, then measure CPU latency in your environment and the false-positive rate on real student sentences first.

Data sources and terms of use

Share this article:

Tags: guardrail, int8, korean, onnx, prompt-injection, quantization, research-preview, safety

Categories:

Updated: