Translation
Transformers
Safetensors
Chinese
Russian
marian
text2text-generation
opus-mt
mnn
android
on-device
Instructions to use Hosstia/opus-mt-zh-ru-opus-mp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Hosstia/opus-mt-zh-ru-opus-mp with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="Hosstia/opus-mt-zh-ru-opus-mp")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Hosstia/opus-mt-zh-ru-opus-mp") model = AutoModelForSeq2SeqLM.from_pretrained("Hosstia/opus-mt-zh-ru-opus-mp", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Hosstia/opus-mt-zh-ru-opus-mp: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/Hosstia/opus-mt-zh-ru-opus-mp/resolve/main/README.md
- Command line
-
hf download hf://Hosstia/opus-mt-zh-ru-opus-mp/README.md
-
curl -L -o README.md https://huggingface.co/Hosstia/opus-mt-zh-ru-opus-mp/resolve/main/README.md
2.04 kB
metadata
language:
- zh
- ru
tags:
- marian
- opus-mt
- translation
- mnn
- android
- on-device
license: apache-2.0
library_name: transformers
pipeline_tag: translation
OPUS-MT zh→ru (Custom Trained)
This is a custom-trained Marian-based translation model for zh→ru.
It was fine-tuned from Helsinki-NLP/opus-mt-zh-en
and converted to MNN format via the mnn-opus-mt-toolkit.
Model Details
| Parameter | Value |
|---|---|
| Architecture | MarianMT (encoder-decoder Transformer) |
| Source language | zh |
| Target language | ru |
| Base model | Helsinki-NLP/opus-mt-zh-en |
| BLEU score | 24.55 |
| chrF score | 41.83 |
| Training pairs | 450,000 |
| Training epochs | 25 |
Usage
With Hugging Face Transformers
from transformers import AutoModelForSeq2SeqLM, MarianTokenizer
model = AutoModelForSeq2SeqLM.from_pretrained("Hosstia/opus-mt-zh-ru-opus-mp")
tokenizer = MarianTokenizer.from_pretrained("Hosstia/opus-mt-zh-ru-opus-mp")
text = "Your source text here"
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs)
translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
With MNN (on-device Android)
Convert to MNN format using the mnn-opus-mt-toolkit:
./run_all.sh --hf-user <username> --src zh --dst ru --format fp16 \
--model-repo Hosstia/opus-mt-zh-ru-opus-mp --tokenizer-repo Hosstia/opus-mt-zh-ru-opus-mp
License
Apache License 2.0 (model weights); see the toolkit repository for details.
Acknowledgments
- Helsinki-NLP for the original OPUS-MT models
- Marian NMT for the training framework
- Alibaba MNN for the on-device inference engine
- Hugging Face for model hosting and the Transformers library