Instructions to use cadazar/han2han-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cadazar/han2han-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cadazar/han2han-it", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("cadazar/han2han-it", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cadazar/han2han-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cadazar/han2han-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cadazar/han2han-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/cadazar/han2han-it
- SGLang
How to use cadazar/han2han-it with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "cadazar/han2han-it" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cadazar/han2han-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "cadazar/han2han-it" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cadazar/han2han-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use cadazar/han2han-it with Docker Model Runner:
docker model run hf.co/cadazar/han2han-it
Han2Han IT
Instruction-tuned checkpoint of Han2Han
(han2han-ul2-base-1-it, step 43153). Han2Han is a 169M-parameter
encoder-decoder model that learns script-invariant representations of Korean
text: a document written in Hanja and its Hangul transcription land at the same
point in embedding space. The recipe (jamo and character-level embedding fusion,
morpheme-aware denoising, bidirectional Hanja-Hangul transcription) is described
in the paper, accepted to Findings of EMNLP 2026.
This repo holds the PyTorch weights, the SentencePiece tokenizer, and the
modeling code needed to load them through the transformers Auto classes with
trust_remote_code=True. Training code, the Flax model, the Flax-to-PyTorch
converter, and the evaluation pipeline live in the GitHub repo.
Usage
Runtime requirements: torch, transformers, sentencepiece, regex, and
numpy (tested with torch 2.12.0 and transformers 5.9.0 on CPU). absl-py is
optional.
import torch
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
repo = "cadazar/han2han-it"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForSeq2SeqLM.from_pretrained(repo, trust_remote_code=True).eval()
prompt = "<|user|>๋ค์ ํ๋ฌธ์ ํ๊ธ๋ก ์ฎ๊ธฐ์์ค:\n้ๅ่ช๋ ไธ็์์ ๊ฐ์ฅ ็งๅญธ็์ธ ๆๅญ์
๋๋ค.<|end_of_turn|>"
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
output = model.generate(**inputs, max_new_tokens=64, use_fixed_length_generation=False)
print(tokenizer.decode(output[0].tolist()))
Prompt format, as used by the SFT collator in the GitHub repo:
- Encoder input:
<|system|>{system}<|user|>{user}<|end_of_turn|>. The system part is optional. - The decoder starts from
<|assistant|>(decoder_start_token_id9) and a turn ends with<|end_of_turn|>(eos_token_id10).
Han2HanTokenizer is a plain SentencePiece wrapper rather than a
PreTrainedTokenizer subclass. It exposes __call__, encode, and decode;
__call__ does not add BOS or EOS tokens, and special tokens written into the
text are mapped to their ids.
Files
| 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 |
spiece.model, tokenizer_config.json |
SentencePiece model (38400 pieces) and tokenizer config |
modeling_han2han.py, han2han_config.py, han2han_tokenizer.py |
modeling code, copied from the GitHub repo at commit 0b858ea5f1c7c5aeb325ba114eb87e335fe05dd9 (modeling_han2han_pytorch.py there) |
The code files differ from the repo copies only where remote-code loading
requires it: sibling imports are relative, optional fla / flax / absl
imports are guarded, the tokenizer and the model resolve Hub repo ids, the
tokenizer logs through a plain logging logger instead of the repo's JAX-aware
helper, and the module-level register_han2han import is replaced by the
auto_map entries.
Instruction tuning
Fine-tuned from the Han2Han pre-trained checkpoint on instruction following,
chain-of-thought reasoning, Hanja-Hangul article transcription, and
summarization data (configs/it-muon-stage_1.yaml in the GitHub repo).
Citation
@inproceedings{han2han2026,
title = {Han2Han: Efficient Language-Specific Character Representation
through Script-Aware Pre-Training for Historical Text Analysis},
author = {Adams, Cellik and Jo, EunKyoung and Kim, Juae},
booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2026},
year = {2026}
}
License
Apache License 2.0, the same as the GitHub repo.
- Downloads last month
- 238