Share this article:

This post follows up on the Building AI for Korean Education and Public Services series. The full stack is described in Building ThakiEdu.

Government offices and education offices receive many documents every day, and someone reads each one and decides which department should handle it. With enough documents this sorting takes real time, and a wrong department means the document bounces between departments before anyone acts on it.

It would be convenient for a model to read the document and pick the department, but when the first choice is wrong the document has to go to another department and come back.

So the model we are releasing does not pick the department. It reads a Korean administrative document and recommends three candidate departments, and the person handling it chooses among them. On a sealed holdout of 1,000 documents, the correct department was in the top 3 for 0.9833 of documents, averaged over three seeds.

The same model’s top-1 accuracy is 0.8743, and macro F1, which weights every department equally, is 0.6839. Those numbers are not good enough for automatic assignment, so the model should not be used to route documents without a human check. This post lays out the evidence for that decision along with the weak departments.

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

ThakiEdu-Classifier-KO-568M-Top3 title card

One document in, three department candidates out

The model is a classifier with 11 outputs on top of the BAAI/bge-m3 encoder (about 568M parameters). The input is [문서 제목] {title} followed on the next line by [문서 본문] {body}, up to 512 tokens. The top 3 of the 11 output logits are shown as candidates.

The department labels are the 11 document categories of the dataset: public administration, science and technology, land management, other, agriculture and fisheries, culture and tourism, law, social welfare, industry and employment, food and health, and environment and weather. This is not the org chart of any specific agency.

Department Top-3 recommendation input and output example An example document written for illustration. The probabilities show the format only and are not measurements.

Automatic assignment and Top-3 recommendation need different accuracy

In automatic assignment, the first choice is the result. Top-1 accuracy of 0.874 means roughly one document in eight goes to the wrong department. We had set an automatic assignment bar in an earlier experiment, and this model did not reach it.

With a Top-3 recommendation, the person handling the document can pick the right department as long as it is among the three candidates. So before training we set the release bar as a 3-seed mean top-3 accuracy of at least 0.98 on the sealed holdout, and released the model for that use.

Automatic assignment and Top-3 recommendation flows compared In automatic assignment, a first-choice error becomes a wrong assignment. In Top-3 recommendation, a person picks from three candidates and catches the first-choice error.

Top-3 of 0.9833 on a sealed 1,000-document holdout

The evaluation criteria were pre-registered and not changed after seeing results. Training used 51,456 documents, and the sealed holdout is 1,000 documents kept apart from training.

We fixed the recipe (weighted cross-entropy, 2 epochs, learning rate 2e-5, batch 32, max length 512) and averaged three seeds (42, 7, 123) without choosing among them by result. The released checkpoint is seed 42, chosen before training.

Metric 3-seed mean Released seed 42
Top-3 accuracy (bar ≥ 0.98) 0.9833 (0.980 / 0.987 / 0.983) 0.980
Top-1 accuracy 0.8743 0.886
Macro F1 0.6839 0.7032

Sealed holdout metrics bar chart The share of documents with the correct department in the top 3 is above 0.98, but top-1 accuracy and macro F1 are lower.

The gap between top-3 and top-1 is why the model is released as a recommender. The low macro F1 is explained by the per-department table below.

Departments with few documents were much weaker

Of the 1,000 holdout documents, 465 are public administration. That department pulls up the overall top-3, and the weakness of small departments disappears into the average.

Department Holdout n Seed 42 top-1 Seed 42 top-3 3-seed mean top-1 3-seed mean top-3
Public administration 465 0.929 0.991 0.915 0.995
Food and health 167 0.904 0.976 0.924 0.982
Social welfare 163 0.841 1.000 0.814 0.996
Other 62 0.823 0.984 0.812 0.984
Law 49 0.918 0.980 0.925 0.973
Land management 31 0.677 0.774 0.656 0.839
Environment and weather 22 0.864 0.955 0.818 0.924
Culture and tourism 21 0.762 0.952 0.683 0.968
Agriculture and fisheries 15 0.867 1.000 0.822 1.000
Industry and employment 5 0.200 0.800 0.200 0.800
Science and technology 0 not measured not measured - -

For the released seed, land management top-3 is 0.774: for about one land management document in four or five, the correct department is not among the three candidates. Industry and employment has only 5 holdout documents, so its numbers are unstable.

Science and technology has 0 holdout documents, so its accuracy is unknown. The released seed predicted science and technology for 8 holdout documents, and all 8 belonged to other departments, which also pulls macro F1 down.

Only FP32 ONNX is included for CPU

Keep onnx/model_fp32.onnx and onnx/model_fp32.onnx_data in the same folder to run CPU inference with onnxruntime. The example is examples/infer_onnx.py and needs only onnxruntime and tokenizers.

Format Top-3 Top-1 agreement with PyTorch CPU latency p50 / p95 (batch 1, 4 threads)
ONNX FP32 (included) 0.980 1.000 422 / 669 ms
ONNX INT8 (not included) 0.979 0.988 153 / 270 ms

INT8 is faster but missed the pre-registered bar (top-3 ≥ 0.98, top-1 agreement ≥ 0.99), so it was left out. The FP32 top-3 of 0.980 sits exactly on the bar, one document out of 1,000.

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

repo = "ThakiCloud/ThakiEdu-Classifier-KO-568M-Top3-v0.1"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()

text = "[문서 제목] 학교 앞 횡단보도 신호등 설치 요청\n[문서 본문] 등하굣길 학생 안전을 위해 …"
with torch.no_grad():
    logits = model(**tok(text, truncation=True, max_length=512, return_tensors="pt")).logits[0]
print([model.config.id2label[i] for i in logits.argsort(descending=True)[:3].tolist()])  # 3 candidates

The example document was written for illustration.

Five things to know before using it

It is not for automatic assignment. Top-1 is 0.874 and macro F1 is 0.684. Use it only in a flow where three candidates are shown and a person chooses.

Check small departments separately. Land management top-3 is 0.774 (seed 42), industry and employment has n=5, and science and technology was not measured. Documents recommended to these departments deserve a second look.

There is one data source. Training and evaluation used a single public administrative document dataset. Generalization to other agencies, other years or differently shaped documents, such as complaints written directly by citizens, was not measured.

Short notices and colloquial input drift toward “other”. In an informal check before release with a few short example notices, the intended department was sometimes missing from the three candidates. This was not an evaluation, so we make no numerical claim.

Numbers for small departments move with the seed. The difference between seed 42 and the 3-seed mean in the table above shows how much.

We re-downloaded it in a fresh environment after release

The public repository (MIT) contains the weights, tokenizer, a config.json with department names filled in, the FP32 ONNX, examples, a per-file sha256 list (release_manifest.json) and the holdout aggregates (eval/holdout_summary.json). The training job saved labels as LABEL_i. Before release, only id2label was filled in with the Korean department names; the weights were not changed.

After publishing, we downloaded the repository anonymously in a fresh environment with no credentials and confirmed that the sha256 of the weights and ONNX files matched the recorded values. On four illustrative documents, PyTorch and ONNX FP32 agreed on the first choice for all four, with a maximum logit difference of 9e-06. These four are a smoke check, not a performance metric.

Closing

The model returns three department candidates per document, and on the sealed holdout the correct department was among them for 0.9833 of documents. It is not accurate enough to assign by first choice alone, so ThakiCloud is evaluating it as a recommendation feature in an administrative document sorting screen where a person makes the final decision.

The next experiment is to check label quality for small departments and add data from independent sources. If you try it, start by measuring top-3 accuracy and per-department recall on a few dozen documents from your own organization.

Data sources and terms of use

Share this article:

Tags: korean, onnx, public-administration, research-preview, text-classification, top-k

Categories:

Updated: