GujinBridge-Qwen3-1.7B-DPO
Source code, training recipes, evaluation reports, and the demo are available in the GujinBridge GitHub repository.
GujinBridge is a Qwen3-1.7B model adapted for classical Chinese translation, modern-to-classical rewriting, and classical Chinese punctuation. This repository contains the fully merged inference weights for the selected release stack:
Qwen3-1.7B -> GujinBridge V5 LoRA SFT -> GujinBridge DPO V1
The DPO checkpoint was selected through frozen-set comparisons against V5 SFT, a targeted V6 SFT run, and two GRPO iterations. The GRPO runs are retained as ablations because they did not consistently outperform DPO.
Evaluation
The frozen evaluation set contains 1,440 examples grouped by source work so that train, validation, and test sources do not overlap.
| Task | Examples | Exact match | Character F1 |
|---|---|---|---|
| Overall | 1,440 | 2.92% | 73.39% |
| Classical -> modern Chinese | 685 | 0.44% | 63.85% |
| Modern -> classical Chinese | 394 | 1.27% | 68.67% |
| Punctuation | 361 | 9.42% | 96.65% |
For punctuation, source-text preservation was 257/361 (71.19%). Character F1 is inflated for punctuation because input and output share most Chinese characters; it should not be interpreted as punctuation-boundary accuracy.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "tzh699/GujinBridge-Qwen3-1.7B-DPO"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
trust_remote_code=True,
)
messages = [
{
"role": "system",
"content": (
"你是古今桥(GujinBridge),一个专注于中国古典文献的智能助手。"
"你能够进行文言文与现代汉语互译、断句标点、释义和基于典籍的问答。"
"回答应忠实原文,区分原文、译文与推断;如果无法确认,应明确说明,"
"不得虚构典籍出处、作者或原文。"
),
},
{
"role": "user",
"content": "将下列古文翻译成现代汉语:\n\n学而时习之,不亦说乎?",
},
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
for name in ("temperature", "top_p", "top_k"):
if hasattr(model.generation_config, name):
setattr(model.generation_config, name, None)
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
repetition_penalty=1.05,
pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id,
)
answer = tokenizer.decode(outputs[0, inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(answer)
Intended use
- Candidate generation for human-assisted classical Chinese translation and punctuation.
- Education, retrieval, and experimentation with SFT/DPO/GRPO pipelines.
- Research demonstrations where outputs are independently checked against primary sources.
Limitations
- Long passages can contain omissions, repetitions, or source-character edits.
- Translations may miss entities, dates, relationships, allusions, or implicit meaning.
- Classical rewriting and punctuation allow multiple valid answers, making single-reference metrics incomplete.
- The model must not be treated as an authoritative edition, textual-critical judgment, or scholarly citation source.
Training data and attribution
The training pipeline uses data derived from gujilab/chinese-classical-corpus. Users should independently verify the
upstream revision, provenance, and license that apply to their use. The training framework is adapted from MedicalGPT.
The GujinBridge code repository includes detailed attribution, experiment reports, and reproducibility scripts.