Downloads · 30 days
9
12% of all-time downloads
J1mmymm/transformer-en-zh-translator
transformer-en-zh-translator is a translation model from J1mmymm. Use it when you need text moved from one language to another. It is set up for transformers. The card lists the license as apache-2.0.
This repository contains an English-to-Chinese MarianMT model fine-tuned from Helsinki-NLP/opus-mt-en-zh, plus the checkpoint of a smaller Transformer trained from scratch for comparison.
Downloads · 30 days
9
12% of all-time downloads
All-time downloads
74
Public
Parameters
77.5M
347 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors310 MB · 89%
From the Hugging Face model README
This repository contains an English-to-Chinese MarianMT model fine-tuned from Helsinki-NLP/opus-mt-en-zh, plus the checkpoint of a smaller Transformer trained from scratch for comparison.
This is not a production translation service. It was trained on short conversational sentences and can mistranslate long, technical, safety-critical, or culturally sensitive text.
The fixed course test split contained 2,991 sentence pairs. Scores were computed with SacreBLEU (tokenize="zh"), chrF++ and TER.
| Model | BLEU | chrF++ | TER | Exact match |
|---|---|---|---|---|
| Scratch Transformer | 20.5691 | 16.0240 | 66.1049 | 3.0090% |
| Base MarianMT (zero-shot) | 41.7833 | 28.7659 | 41.7261 | 2.1398% |
| Fine-tuned MarianMT | 52.4721 | 39.2654 | 30.8395 | 17.8536% |
These scores describe this fixed local split only and should not be interpreted as general-domain translation quality.
Helsinki-NLP/opus-mt-en-zh2e-5 with cosine decayThe sentence content appears to derive from the Tatoeba/ManyThings English–Mandarin collection. The course files did not retain per-sentence attribution metadata, so the corpus itself is not redistributed here. See the project repository for the expected data format and reproducibility notes.
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
model_id = "J1mmymm/transformer-en-zh-translator"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
inputs = tokenizer("Machine learning is useful.", return_tensors="pt")
outputs = model.generate(**inputs, num_beams=4, max_new_tokens=64)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
scratch/scratch_transformer.pt contains the state dictionary, English and Chinese vocabularies, exact architecture/training configuration, best validation loss, and best epoch for the custom nn.Transformer model. Load it with en_zh_translator.load_scratch_checkpoint from the GitHub project.
The model inherits limitations and biases from the base model and the short conversational fine-tuning corpus. References may have multiple valid translations, so exact-match is a particularly strict and incomplete metric. Human review is required before consequential use.
The base model is Apache-2.0. Project code and this derived model release are published under Apache-2.0. Dataset text is not included; users preparing their own Tatoeba/ManyThings split must follow its attribution requirements.