Instructions to use TigreGotico/opus-mt-hy-en-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TigreGotico/opus-mt-hy-en-onnx 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="TigreGotico/opus-mt-hy-en-onnx")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("TigreGotico/opus-mt-hy-en-onnx") model = AutoModelForSeq2SeqLM.from_pretrained("TigreGotico/opus-mt-hy-en-onnx", device_map="auto") - Notebooks
- Google Colab
- Kaggle
opus-mt-hy-en-onnx
ONNX export (fp32 + dynamic int8) of Helsinki-NLP/opus-mt-hy-en,
a Marian (hy -> en) translation model from the Helsinki-NLP OPUS-MT project.
License: apache-2.0, inherited unchanged from the base model.
Contents
| Files | What it is |
|---|---|
encoder_model.onnx, decoder_model.onnx, decoder_with_past_model.onnx |
ONNX, float32 |
int8/ |
same three graphs, dynamic int8 (QInt8, MatMul only, /lm_head/MatMul excluded) |
source.spm, target.spm, vocab.json |
MarianTokenizer over the original sentencepiece models |
fp32 size: 868 MB (three graphs) | int8 size: 679 MB
Usage
from optimum.onnxruntime import ORTModelForSeq2SeqLM
from transformers import AutoTokenizer
repo = "TigreGotico/opus-mt-hy-en-onnx"
tok = AutoTokenizer.from_pretrained(repo)
model = ORTModelForSeq2SeqLM.from_pretrained(repo, use_cache=True, use_merged=False) # fp32
# int8: ORTModelForSeq2SeqLM.from_pretrained(repo, subfolder="int8", use_cache=True, use_merged=False)
inputs = tok("Այսօր եղանակը շատ գեղեցիկ է:", return_tensors="pt")
out = model.generate(**inputs, num_beams=4, max_new_tokens=64)
print(tok.decode(out[0], skip_special_tokens=True))
Parity with the original PyTorch model
10 general-domain Armenian sentences (source language for this hy->en
pair), exact-string-match of generated output against MarianMTModel.generate()
on the original Helsinki-NLP/opus-mt-hy-en checkpoint.
parity:
fp32_greedy: 1.00 # 10/10
fp32_beam4: 1.00 # 10/10
int8_greedy: 1.00 # 10/10
int8_beam4: 0.90 # 9/10
| Decoding | fp32 exact match | int8 exact match |
|---|---|---|
| greedy (num_beams=1) | 10/10 (100.0%) | 10/10 (100.0%) |
| beam=4 | 10/10 (100.0%) | 9/10 (90.0%) |
fp32 is an exact reproduction of the original model at both decoding settings, and int8 matches it almost everywhere - the best int8 agreement observed among the Armenian/Azerbaijani models converted in this batch. The single beam=4 disagreement was inspected by hand: ref "Can you help me find the next train station?" vs int8 "Can you help me find my nearby railway station?" - a paraphrase, not a degradation.
An earlier version of this card reported int8 80%/90% from a harness bug - the parity script had reused a fixed English sentence set across all opus-mt pairs, but this model's source language is Armenian, not English, so that measurement compared the model against out-of-distribution input and was discarded. The numbers above are the corrected, re-measured values using real Armenian source sentences.
- Downloads last month
- 20
Model tree for TigreGotico/opus-mt-hy-en-onnx
Base model
Helsinki-NLP/opus-mt-hy-en