Han2Han (169M parameters, encoder-decoder) trained with reinforcement learning to convert Korean text between its two scripts, in both directions:
์กฐ์ ๋ฏธ์ to ๆ้ฎฎ็พ่ก).It is the last of three checkpoints, after
cadazar/han2han-pt (pre-trained)
and cadazar/han2han-it
(instruction-tuned). It starts from han2han-it and takes its prompts the
same way. The paper (Findings of EMNLP 2026) reports on the first two. This
checkpoint is follow-up work, and its sentence embeddings have not been
evaluated.
On 256 sentences from 1920s newspapers, held out from the reinforcement learning, greedy decoding:
han2han-it |
this model | |
|---|---|---|
| Hangul to Hanja: share of the original Hanja restored | 0.31 | 0.63 |
| sentences restored without any error | 1% | 6% |
| Hanja to Hangul: share of the Hanja read correctly | 0.89 | 0.93 |
| sentences transcribed without any error | 34% | 50% |
| outputs that end on their own (to Hanja / to Hangul) | 99% / 100% | 100% / 100% |
| the demo article (1922, 478 characters, held out of every split) in chunks of at most 120 characters: Hanja restored | 0.81 | 0.86 |
Restoring Hanja is the hard direction. The Hangul reading does not say which of several same-sounding characters was meant, and the model has to choose from context. Most restored sentences therefore contain at least one wrong character, and the output needs checking against a source before it is quoted. The errors that remain:
่ฝๆญป for ่ฝๅฏซ, ๆ
ๆธ for ๆ
็ท).็ถ ้ฆๅฑ for ็ถ ้ๅฑ).๋จ์ for ๅฎ็ด).ๅตไฝ for ็ฟไฝ), which changes the reading as well.Sampling at temperature 0.6 scores below greedy decoding in both directions (0.60 and 0.91). A second training run with another seed and another held-out split reached 0.67 and 0.92, so differences of a few points between runs are noise.
The newspapers these sentences come from were part of pre-training, so the text is held out from the fine-tuning stages, not unseen by the model.
The model needs torch and transformers (tested with torch 2.14.1 and
transformers 5.18.0 on CPU). trust_remote_code=True is needed because the
model class ships in this repo.
The task prompt goes in the system message and the text alone in the user
message, as in han2han-it. The reinforcement learning used one wording per
direction, so use them as written.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "cadazar/han2han-rl"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval()
TO_HANJA = "ํ๊ธ์ ํ์๋ก ์ ์ฌํ์์ค:"
TO_HANGUL = "ํ์๋ฅผ ํ๊ธ๋ก ์ ์ฌํ์์ค:"
def convert(task_prompt, text):
messages = [
{"role": "system", "content": task_prompt},
{"role": "user", "content": text},
]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
)
budget = 2 * len(tokenizer(text).input_ids) + 8
with torch.no_grad():
output = model.generate(**inputs, max_new_tokens=budget, do_sample=False)
return tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
hangul = (
"๋จ์ํ ์ค์ผ์น๋ ์นด๋ฉ๋ผ์ ์ ์ฌ๊ฐ ์๋๋ผ ์๊ฐ์ ์์ ์ ์ ์์ ์ ์ฒด์ ์ธ ์๊ณ๋ก "
"์ด๋ฃจ์ด์ง๋ ๊ฐ์ฅ ์ฌ์ค์ ์ธ ํํ์ ๋งํ๋ ๊ฒ์ด๋ค."
)
hanja = convert(TO_HANJA, hangul)
print(hanja)
# ๋จ์ํ ์ค์ผ์น๋ ์นด๋ฉ๋ผ็ ่ฝๆญป๊ฐ ์๋๋ผ ไฝๅฎถ์ ่่ก็ ๆ
ๆธ์ ๅ
จ้ซ็์ธ ็ผ็๋ก
# ์ด๋ฃจ์ด์ง๋ ๊ฐ์ฅ ไบๅฏฆ็์ธ ่กจ็พ์ ๋งํ๋ ๊ฒ์ด๋ค.
print(convert(TO_HANGUL, hanja))
# ๋จ์ํ ์ค์ผ์น๋ ์นด๋ฉ๋ผ์ ์ ์ฌ๊ฐ ์๋๋ผ ์๊ฐ์ ์์ ์ ์ ์์ ์ ์ฒด์ ์ธ ์๊ณ๋ก
# ์ด๋ฃจ์ด์ง๋ ๊ฐ์ฅ ์ฌ์ค์ ์ธ ํํ์ ๋งํ๋ ๊ฒ์ด๋ค.
The outputs are shown as generated (each is one line). The original sentence
reads ๅฎ็ดํ ์ค์ผ์น๋ ์นด๋ฉ๋ผ็ ่ฝๅฏซ๊ฐ ์๋๋ผ ไฝๅฎถ์ ่่ก็ ๆ
็ท์ ๅ
จ้ซ็์ธ ็ผ็๋ก ์ด๋ฃจ์ด์ง๋ ๊ฐ์ฅ ๅฏซๅฏฆ็์ธ ่กจ็พ์ ๋งํ๋ ๊ฒ์ด๋ค.. The model left ๋จ์
in Hangul and chose same-sounding characters for three words (่ฝๆญป, ๆ
ๆธ,
ไบๅฏฆ็). han2han-it returns this sentence in Hangul, unchanged.
han2han-it), but for long
texts it is safer to split at sentence boundaries into pieces of a few
hundred characters and convert each piece.2 * input tokens + 8 leaves room and stops a runaway
output.enable_thinking=True, but neither
this model nor han2han-it learned a separate reasoning step. Leave it off.The model works with the transformers server and its chat client:
transformers serve --trust-remote-code
transformers chat cadazar/han2han-rl --system-prompt "ํ๊ธ์ ํ์๋ก ์ ์ฌํ์์ค:"
AutoModelForCausalLM loads Han2HanForCausalLM, a wrapper that takes the
rendered chat prompt as one sequence and returns the prompt followed by the
reply. AutoModelForSeq2SeqLM loads the encoder-decoder itself. The
han2han-it model card describes
both, the prompt format, and the tokenizer.
GRPO from han2han-it (main), 300 steps, all weights trained in fp32:
The reinforcement-learning stage is in the GitHub repo under rl/ (the rewards, the JAX trainer, the
optimizer recipe and the command that produced this checkpoint). The orbax checkpoint it saved is this repo's
flax revision (step 300, with the run's logs under
run/; hf download cadazar/han2han-rl --revision flax --local-dir han2han-rl-flax), its start the
flax revision of cadazar/han2han-it, and the data a public re-run
reads is cadazar/han2han-rl-data (the
run's own pool and held-out sentences cannot be redistributed, so the dataset card gives the numbers on
its public evaluation sentences).
| File | Contents |
|---|---|
model.safetensors |
fp32 weights, 169.2M parameters, plus the jbu / cbu subword bucket tables |
config.json, generation_config.json |
model and generation config, with auto_map entries for the Auto classes |
tokenizer.json, tokenizer_config.json, chat_template.jinja |
fast tokenizer (38400 pieces) and chat template, the same as in han2han-it |
spiece.model |
the SentencePiece model tokenizer.json was built from |
modeling_han2han.py, han2han_config.py |
modeling code from the GitHub repo at commit af1330e, the same files as in han2han-it |
Published in Findings of the Association for Computational Linguistics: EMNLP 2026 (Budapest), pages 45857-45876: https://aclanthology.org/2026.findings-emnlp.2146/
@inproceedings{adams-etal-2026-han2han,
title = "{H}an2{H}an: Efficient Language-Specific Character Representation through Script-Aware Pre-Training for Historical Text Analysis",
author = "Adams, Cellik and
Jo, EunKyoung and
Kim, Juae",
editor = "Lee, Hung-Yi and
Dev, Sunipa and
Li, Jessy and
Elliott, Desmond",
booktitle = "Findings of the {A}ssociation for {C}omputational {L}inguistics: {EMNLP} 2026",
month = oct,
year = "2026",
address = "Budapest, Hungary",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2026.findings-emnlp.2146/",
pages = "45857--45876",
ISBN = "979-8-89176-462-0"
}
Apache License 2.0, the same as the GitHub repo.
cadazar/han2han-it