ngocdang83 commited on
Commit
9bf8c2f
·
verified ·
1 Parent(s): ca8c63a

Add README

Browse files
Files changed (1) hide show
  1. README.md +250 -0
README.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ - vi
5
+ license: cc-by-4.0
6
+ library_name: transformers
7
+ pipeline_tag: translation
8
+ tags:
9
+ - translation
10
+ - chinese-vietnamese
11
+ - marian
12
+ - webnovel
13
+ - xianxia
14
+ - nmt
15
+ - machine-translation
16
+ - asymmetric-transformer
17
+ datasets:
18
+ - ngocdang83/tran-vi-teacher
19
+ - chi-vi/hirashiba-mt-zh2vi-b-filtered
20
+ base_model:
21
+ - Moleys/hirashiba-mt-medium
22
+ ---
23
+
24
+ # HachimiMT-60: Chinese→Vietnamese Web-Novel Translation Model
25
+
26
+ A **56.94M-parameter Marian-class** Chinese-to-Vietnamese translation model
27
+ optimized for **web-novel content** (xianxia, modern, cross-domain).
28
+
29
+ ## TL;DR
30
+
31
+ | Aspect | Value |
32
+ |---|---|
33
+ | **Params** | 56.94M |
34
+ | **Architecture** | Asymmetric Marian (8 encoder + 2 decoder, d_model 512) |
35
+ | **Vocab** | Custom SPM-BPE 24k joint ZH+VI |
36
+ | **Max position** | 512 |
37
+ | **Best for** | Xianxia + cross-domain web-novel paragraph translation |
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ from transformers import AutoTokenizer, MarianMTModel
43
+ import torch
44
+
45
+ tokenizer = AutoTokenizer.from_pretrained("ngocdang83/HachimiMT-60-zh-vi")
46
+ model = MarianMTModel.from_pretrained("ngocdang83/HachimiMT-60-zh-vi").to("cuda").eval()
47
+
48
+ src = "他必须得抓紧时间了。凌伊山掏出手机,查询起了临江市最近开往雪霏市的机票。"
49
+ inp = tokenizer(src, return_tensors="pt", truncation=True, max_length=256).to("cuda")
50
+ with torch.inference_mode():
51
+ out = model.generate(
52
+ **inp,
53
+ max_new_tokens=300,
54
+ num_beams=4,
55
+ early_stopping=True,
56
+ no_repeat_ngram_size=2,
57
+ repetition_penalty=1.2,
58
+ )
59
+ print(tokenizer.decode(out[0], skip_special_tokens=True))
60
+ # Output: "Hắn phải tranh thủ thời gian rồi. Lăng Y Sơn lấy điện thoại ra, tra
61
+ # vé máy bay gần nhất từ thành phố Lâm Giang đến thành phố Tuyết Phi."
62
+ ```
63
+
64
+ ## Speed Benchmark
65
+
66
+ Tested on RTX 5070 Ti Laptop, `num_beams=4`, mixed test set (20 short + 20 medium + 20 long rows).
67
+
68
+ | Model | Params | Mean Latency | max_position | Notes |
69
+ |---|---:|---:|---:|---|
70
+ | [Hirashiba-tiny](https://huggingface.co/chi-vi/hirashiba-mt-tiny-zh-vi) | 15.1M | **377ms** | 512 | Fastest |
71
+ | [Hirashiba-medium](https://huggingface.co/Moleys/hirashiba-mt-medium) | 57.07M | 495ms | 128 | Truncates paragraphs |
72
+ | **HachimiMT-60** (this) | 56.94M | **603ms** | 512 | Handles long paragraph without truncation |
73
+
74
+ Per-bucket mean latency (ms):
75
+
76
+ | Bucket | HachimiMT-60 | Hirashiba-medium | Hirashiba-tiny |
77
+ |---|---:|---:|---:|
78
+ | short (~70-120ch) | 330 | 390 | 310 |
79
+ | medium (~150-250ch) | 626 | 546 | 430 |
80
+ | long (>250ch) | 853 | 548 | 390 |
81
+
82
+ ⚠️ **Hirashiba-medium and Hirashiba-tiny truncate** on medium/long buckets due
83
+ to `max_position_embeddings=128`, which caps output to ~120 tokens regardless
84
+ of source length. Their lower latency on long bucket reflects truncated output
85
+ rather than faster decoding. HachimiMT-60 produces full-length output up to
86
+ ~1000 chars without truncation.
87
+
88
+ For ultra-low-latency short-content use cases, consider Hirashiba-tiny.
89
+ For paragraph-level web-novel translation, HachimiMT-60 is recommended.
90
+
91
+ ## Architecture
92
+
93
+ ```
94
+ MarianMTModel:
95
+ vocab_size: 24000 # custom SPM-BPE joint ZH+VI
96
+ d_model: 512
97
+ encoder_layers: 8 # deep encoder for source understanding
98
+ decoder_layers: 2 # shallow decoder for fast generation
99
+ encoder_attention_heads: 8
100
+ decoder_attention_heads: 8
101
+ encoder_ffn_dim: 3072
102
+ decoder_ffn_dim: 3072
103
+ max_position_embeddings: 512 # 4× larger than Hirashiba's 128
104
+ share_encoder_decoder_embeddings: true
105
+ tie_word_embeddings: true
106
+ scale_embedding: true
107
+ activation_function: swish
108
+ ```
109
+
110
+ Total params: **56,935,424 (~57M)**.
111
+
112
+ The **asymmetric design** (deep encoder, shallow decoder) provides good
113
+ encoder understanding while keeping decoding fast. `max_position=512` allows
114
+ handling paragraph-level inputs that smaller models truncate.
115
+
116
+ ## Training Datasets
117
+
118
+ Primary training sources:
119
+
120
+ 1. **[ngocdang83/tran-vi-teacher](https://huggingface.co/datasets/ngocdang83/tran-vi-teacher)** —
121
+ 350k strict-clean Chinese-Vietnamese parallel from Gemini 2.5/3.0/3.1
122
+ teacher (Pro/Flash/Flash-Lite tiers). Provides paragraph-level training
123
+ examples + cross-domain coverage (urban, fantasy, sci-fi, history).
124
+
125
+ 2. **[chi-vi/hirashiba-mt-zh2vi-b-filtered](https://huggingface.co/datasets/chi-vi/hirashiba-mt-zh2vi-b-filtered)** —
126
+ Filtered Chinese-Vietnamese translation dataset for web-novel domain.
127
+
128
+ 3. **Gold teacher** generated by Gemini API for additional quality-targeted
129
+ training examples.
130
+
131
+ ## Decode Configuration
132
+
133
+ Recommended generation parameters:
134
+
135
+ ```python
136
+ out = model.generate(
137
+ **inputs,
138
+ max_new_tokens=300, # adjust based on expected length
139
+ num_beams=4, # quality/speed tradeoff
140
+ early_stopping=True,
141
+ no_repeat_ngram_size=2, # prevent repetition
142
+ repetition_penalty=1.2,
143
+ )
144
+ ```
145
+
146
+ For shorter inputs (single sentence), reduce `max_new_tokens=150`.
147
+ For long paragraphs, increase to `400`.
148
+
149
+ ## Intended Uses
150
+
151
+ ### Recommended
152
+
153
+ 1. **Chinese-Vietnamese web-novel translation** (xianxia, tu tiên, fantasy, sci-fi)
154
+ 2. **Paragraph-level translation** (handles up to ~1000 chars output without truncation)
155
+ 3. **Cross-domain content** (Lovecraftian, urban, school, military)
156
+ 4. **Production deployment** with batched inference
157
+
158
+ ### Not Recommended
159
+
160
+ 1. **Non-Chinese sources** (ZH→VI only, not bidirectional)
161
+ 2. **Ultra-low latency requirements** (<300ms) — use a smaller model
162
+ 3. **Traditional Chinese (繁體) input** — model trained on Simplified
163
+ Chinese (简体). Traditional characters may degrade output quality;
164
+ convert to Simplified first (e.g. via `opencc`).
165
+ 4. **Bilingual editing/post-editing** without verification — automated MT
166
+ should be reviewed before publication.
167
+
168
+ ## Limitations
169
+
170
+ 1. **Hallucination on rare proper nouns**: Western names (Klein, Audrey,
171
+ Bernadette) usually preserved, but uncommon proper nouns may hallucinate.
172
+ 2. **Trained on web-novel corpus**: scientific, legal, or news domains
173
+ may give suboptimal results.
174
+ 3. **Output length asymptote**: outputs >1000 chars may degrade.
175
+ 4. **Simplified Chinese only**: Traditional Chinese inputs untested and
176
+ likely to degrade.
177
+
178
+ ## Evaluation Methodology
179
+
180
+ Quality validation uses a **trio AI reviewer pattern** for cross-validated
181
+ human-style preference judgments without single-model bias.
182
+
183
+ ### Reviewers
184
+
185
+ Three independent CLI sessions, each using a different LLM context:
186
+
187
+ - **Reviewer 1**: `gemini-3.1-pro` via Gemini CLI
188
+ - **Reviewer 2**: `gemini-3.5-flash` via Gemini CLI (different temperature)
189
+ - **Reviewer 3**: `gemini-3.5-flash` via Gemini CLI (independent session)
190
+
191
+ Each reviewer reads **one** review TSV in isolation — they cannot see other
192
+ reviewers' outputs.
193
+
194
+ ### Scoring
195
+
196
+ Per row, per model:
197
+ - **Severity 0-3** scale (0 = OK / acceptable, 1 = minor error, 2 = moderate
198
+ error, 3 = severe error — hallucination, truncation, or word salad)
199
+ - **Winner** pick: choose the best of 4 model outputs, or `tie` / `all_bad`
200
+ - **winner_reason** short text (model-specific failure modes or strengths)
201
+
202
+ ### Aggregation
203
+
204
+ - **Pooled severity** = mean of all severity scores across reviewers (lower = better)
205
+ - **Winner aggregate** = vote count across 180 judgments (60 rows × 3 reviewers)
206
+ - **Trio consensus** = rows where all 3 reviewers agree on the same winner
207
+ (highest-confidence signal)
208
+
209
+ ### Test Sets
210
+
211
+ Two complementary evaluation sets covering web-novel translation diversity:
212
+
213
+ 1. **Cross-novel paragraph** (60 rows, 20 short + 20 medium + 20 long buckets)
214
+ — random paragraphs from two web-novels (Lovecraftian fantasy + sci-fi
215
+ mecha), tests cross-domain + long-output handling.
216
+
217
+ 2. **Xianxia in-distribution** (60 rows, 30 classical xianxia + 30 modern
218
+ xianxia hybrid chapter excerpts) — tests xianxia genre quality and
219
+ register polish (Hán Việt accuracy, tu tiên vocabulary, modern colloquial
220
+ Vietnamese register).
221
+
222
+ ### Anti-Bias Rules
223
+
224
+ To prevent single-reviewer drift:
225
+ - Each session opens **only one review file** (no cross-read)
226
+ - Anti-boilerplate rules enforced (no default severity=0, no default winner=tie)
227
+ - Reviewer-specific bias patterns identified post-hoc and weighted in interpretation
228
+
229
+ ## Citation
230
+
231
+ ```bibtex
232
+ @misc{hachimimt60-2026,
233
+ author = {ngocdang83 and chi-vi},
234
+ title = {HachimiMT-60: Chinese-to-Vietnamese Web-Novel Translation},
235
+ year = {2026},
236
+ publisher = {Hugging Face},
237
+ url = {https://huggingface.co/ngocdang83/HachimiMT-60-zh-vi}
238
+ }
239
+ ```
240
+
241
+ ## License
242
+
243
+ CC-BY-4.0 — free use with attribution. Training data includes Gemini API
244
+ teacher distillation; downstream users should verify current Gemini API
245
+ terms for derivative-work training.
246
+
247
+ ## Attribution
248
+
249
+ Shared by [chi-vi](https://huggingface.co/chi-vi) — Chinese↔Vietnamese
250
+ translation research community.