Share this article:

This post follows up on the Building AI for Korean Education and Public Services series. Part 2, Does a reranker always improve retrieval?, covered how v0.1 lowered top-1.

Anyone building statute question answering runs into this. Retrieval has put the correct article among the candidates, but the neighboring article sits in first place. You add a reranker, and the share of correct articles in the top 8 goes up while first-place accuracy goes down. The downstream language model usually reads the first article first, so this gap goes straight into answer quality.

That is what happened with v0.1, released last month. So we re-mined the wrong candidates used in training (hard negatives) from the candidate distribution the reranker actually receives at serving time, and trained v0.2. That is the only change.

On a sealed holdout of 679 items, never used for training, diagnosis or selection, v0.2 reaches recall@1 0.6598: +0.1429 over dense retrieval alone (0.5169) and +0.2283 over v0.1 (0.4315). The recommended serving order, which fuses the dense ranking with the v0.2 ranking (F_r7), reaches 0.7290. This post covers what changed, how we measured it, and how far the numbers can be trusted.

Model: ThakiCloud/ThakiEdu-Reranker-KO-v0.2 · Collection: ThakiEdu

ThakiEdu-Reranker-KO-v0.2 title card

A reranker gives one score to a query and article pair

A reranker (cross-encoder) reads a query and one candidate document together and outputs a single relevance score. Embedding retrieval turns the query and the document into separate vectors and compares them. A reranker reads both as one input, so it can compare them more finely. The cost is one forward pass per candidate, so it only runs on the few dozen candidates the earlier stage selects.

v0.2 is a cross-encoder with a 24-layer XLM-RoBERTa body and one output. It continues training from the v0.1 weights, whose original base is BAAI/bge-reranker-v2-m3. The query is question + newline + first 1,000 characters of the passage, the document is <statute name> Article <N> (<title>) <first 600 characters of the article>, and the model reads up to 512 tokens.

Reranker input and output example An example built from a newly written query and real statute article titles. The scores show the format only and are not measurements.

Candidates are the top 50 after fusing BM25 and ThakiEdu-Embedding-KO-v0.1 dense results with RRF (Reciprocal Rank Fusion). The reranker only reorders these 50.

We re-mined training negatives from serving candidates

Hard negatives are wrong documents that are easy to confuse with the right one. The reranker learns to separate the correct article from these negatives, so the choice of negatives decides what the model learns to tell apart.

In Part 2 we wrote down a hypothesis for why v0.1 lowered top-1 behind a strong embedding: the training candidate distribution differs from the serving candidate distribution. v0.2 follows that hypothesis and changes one thing.

The training hard negatives were re-mined from the actual serving candidate distribution: wrong articles that ThakiEdu-Embedding-KO dense retrieval ranked high, and articles that v0.1 scored above the correct one.

Training candidates for v0.1 and v0.2 v0.2 trains on negatives drawn from the candidates the reranker actually receives at serving time. The input format and candidate generation stay the same.

The training source is the training-split passages of AI Hub (AI-Hub) Financial and Legal Document Machine Reading Comprehension (71610), with every evaluation passage excluded. The data is small: 351 training groups and 33 validation groups. We trained three seeds, and the released checkpoint is seed 20261129, fixed before seeing results.

+0.143 over dense alone on a sealed 679-item holdout

The evaluation criteria were pre-registered before the evaluation code was written and were not changed afterwards. The holdout has 800 statute-grounding items and was evaluated once. The denominator is the 679 items whose correct article exists in the corpus (Legalize-KR v2, 207,591 articles).

The other 121 items were dropped because their correct article is no longer in the current corpus, for example after amendment or repeal. Training passages and holdout passages overlap in 0 rows.

Final order recall@1 recall@3 recall@8 recall@50
Dense (ThakiEdu-Embedding-KO-v0.1) alone 0.5169 0.7982 0.8498 0.8940
RRF top-50 → v0.1 reranker 0.4315 0.6951 0.8321 0.8969
RRF top-50 → v0.2 0.6598 0.8218 0.8689 0.8969
F_r5 (dense top-20 + v0.1, RRF) 0.6289 0.8027 0.8689 0.8969
F_r7 (dense top-20 + v0.2, RRF), recommended 0.7290 0.8351 0.8733 0.8969

Sealed holdout recall@1 bar chart v0.1 scored below dense alone on recall@1; v0.2 is above both dense alone and v0.1. The recommended serving order F_r7 is highest at 0.7290.

recall@1 differences from a paired item bootstrap (2,000 resamples, 95% confidence intervals):

  • v0.2 − dense alone: +0.1429 [0.1031, 0.1826]
  • v0.2 − v0.1: +0.2283 [0.1929, 0.2651]
  • F_r7 − v0.2: +0.0692 [0.0442, 0.0943]
  • F_r7 − dense alone: +0.2121 [0.1782, 0.2445]

On recall@8, v0.2 is also above dense alone by +0.0191 [0.0044, 0.0339] and above v0.1 by +0.0368 [0.0206, 0.0560]. All four pre-registered pass criteria were met (at least 200 resolvable items, lower CI bound of v0.2 − dense recall@1 above 0, v0.2 recall@8 no more than 0.02 below v0.1, lower CI bound of v0.2 − v0.1 recall@1 above 0), and the verdict is HOLDOUT_PASS.

Because the training negatives were the only change, we attribute the difference to mining hard negatives from serving candidates. It points the same way as the hypothesis in Part 2. The holdout was evaluated once with one released seed, though, and on the dev slices below the effect size varied with the seed.

F_r7 fuses the dense top-20 ranking and the v0.2 top-50 ranking with RRF (k=60). Before running the holdout we fixed a rule: recommend F_r7 if the lower CI bound of F_r7 − v0.2 recall@1 is above 0 and recall@8 does not drop by more than 0.02. With a lower bound of 0.0442 and recall@8 of 0.8733, it passed.

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

repo = "ThakiCloud/ThakiEdu-Reranker-KO-v0.2"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()

query = "학교가 학부모 연락처를 모을 때 근거가 되는 조문은?\n" + "가정통신문 회신서에 보호자 휴대전화 번호를 적도록 했다."[:1000]
docs = [
    "개인정보 보호법 제15조 (개인정보의 수집ㆍ이용) …",
    "도로교통법 제17조 (자동차등과 노면전차의 속도) …",
]
with torch.no_grad():
    batch = tok([query] * len(docs), docs, padding=True,
                truncation="longest_first", max_length=512, return_tensors="pt")
    scores = model(**batch).logits[:, 0]
print(scores)  # higher means more relevant

The query above was written for illustration. examples/rerank_fusion.py in the repository contains both the reranker-only order and the F_r7 order.

On the dev slices, the effect size depended on the seed

The two dev slices used repeatedly for diagnosis during training (B: 167 resolvable, C: 175) are auxiliary, not sealed.

Final order B recall@1 C recall@1 B recall@8 C recall@8
Dense alone 0.461 0.514 0.868 0.851
RRF top-50 → v0.1 0.371 0.383 0.862 0.823
RRF top-50 → v0.2 0.647 0.606 0.898 0.851

Across three seeds, v0.2 recall@1 ranged 0.623 to 0.653 on B and 0.589 to 0.663 on C. On slice C, seed 20261130 was +0.074 over dense and its 95% interval included 0. The direction held across seeds, but the size of the effect did not. The holdout value of 0.6598 falls inside the dev range.

Five things to know before using it

The improvement applies to statute queries that come with a passage. Queries pair a question with a passage that mentions the statute, and the corpus is the current Legalize-KR v2. Short questions without a passage and queries outside the statute pool were not measured. Domains other than statutes were not evaluated, and this is not a legal-advice tool.

recall@50 is 0.8969 for every reranker configuration. The reranker only reorders, so candidate generation sets the ceiling. The next improvement has to come from candidate generation (embedding and statute pool).

The training set is small and one seed is released. 351 training groups and 33 validation groups, and the holdout was evaluated once.

There is no ONNX in this release. Only model.safetensors ships. v0.1 provides an FP32 ONNX. The INT8 conversion of v0.1 flipped rankings, so there is no plan for an INT8 release.

v0.1 stays as it was. v0.2 is a separate checkpoint with different weights, published in its own repository. Users pinned to v0.1 keep the model they tested.

We re-downloaded it in a fresh environment after release

The public repository (Apache-2.0) contains the weights, tokenizer, model card, examples, a per-file size and sha256 list (release_manifest.json) and the holdout aggregates (eval/holdout_summary.json). After publishing, we downloaded the repository anonymously in a fresh environment with no credentials.

The sha256 of the weights and tokenizer matched the recorded values. On three illustrative queries, the relevant article scored above the unrelated one, and the F_r7 fusion example ran. These three are a smoke check, not a performance metric.

Closing

v0.2 reversed v0.1’s top-1 drop with one change, mining training negatives from the candidates seen at serving time, and beats dense alone on recall@1 by +0.143 on the sealed holdout. ThakiCloud is evaluating this reranker in the ThakiEdu retrieval path so that education and public-sector customers can use statute-grounded search without sending data outside.

If you try it, start by putting v0.2 on top of the dense retrieval you already run and compare recall@1 for the reranker-only order and the F_r7 order on your own queries. The full stack is described in Building ThakiEdu.

Data sources and terms of use

Share this article:

Tags: cross-encoder, hard-negative, korean, legal-rag, rag, reranker, research-preview

Categories:

Updated: