Instructions to use TigreGotico/opus-mt-en-az-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TigreGotico/opus-mt-en-az-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-en-az-onnx")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("TigreGotico/opus-mt-en-az-onnx") model = AutoModelForSeq2SeqLM.from_pretrained("TigreGotico/opus-mt-en-az-onnx", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- README.md +65 -0
- config.json +55 -0
- decoder_model.onnx +3 -0
- decoder_with_past_model.onnx +3 -0
- encoder_model.onnx +3 -0
- generation_config.json +16 -0
- int8/decoder_model.onnx +3 -0
- int8/decoder_with_past_model.onnx +3 -0
- int8/encoder_model.onnx +3 -0
- source.spm +3 -0
- special_tokens_map.json +5 -0
- target.spm +3 -0
- tokenizer_config.json +39 -0
- vocab.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
source.spm filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
target.spm filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Helsinki-NLP/opus-mt-en-az
|
| 4 |
+
base_model_relation: quantized
|
| 5 |
+
tags:
|
| 6 |
+
- onnx
|
| 7 |
+
- translation
|
| 8 |
+
- marian
|
| 9 |
+
library_name: transformers
|
| 10 |
+
pipeline_tag: translation
|
| 11 |
+
language:
|
| 12 |
+
- en
|
| 13 |
+
- az
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# opus-mt-en-az-onnx
|
| 17 |
+
|
| 18 |
+
ONNX export (fp32 + dynamic int8) of [`Helsinki-NLP/opus-mt-en-az`](https://huggingface.co/Helsinki-NLP/opus-mt-en-az),
|
| 19 |
+
a Marian (en -> az) translation model from the Helsinki-NLP OPUS-MT project.
|
| 20 |
+
|
| 21 |
+
**License:** apache-2.0, inherited unchanged from the base model.
|
| 22 |
+
|
| 23 |
+
## Contents
|
| 24 |
+
|
| 25 |
+
| Files | What it is |
|
| 26 |
+
|---|---|
|
| 27 |
+
| `encoder_model.onnx`, `decoder_model.onnx`, `decoder_with_past_model.onnx` | ONNX, float32 |
|
| 28 |
+
| `int8/` | same three graphs, dynamic int8 (`QInt8`, `MatMul` only, `/lm_head/MatMul` excluded) |
|
| 29 |
+
| `source.spm`, `target.spm`, `vocab.json` | `MarianTokenizer` over the original sentencepiece models |
|
| 30 |
+
|
| 31 |
+
fp32 size: 485 MB (three graphs) | int8 size: 295 MB
|
| 32 |
+
|
| 33 |
+
## Usage
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
from optimum.onnxruntime import ORTModelForSeq2SeqLM
|
| 37 |
+
from transformers import AutoTokenizer
|
| 38 |
+
|
| 39 |
+
repo = "TigreGotico/opus-mt-en-az-onnx"
|
| 40 |
+
tok = AutoTokenizer.from_pretrained(repo)
|
| 41 |
+
model = ORTModelForSeq2SeqLM.from_pretrained(repo, use_cache=True, use_merged=False) # fp32
|
| 42 |
+
# int8: ORTModelForSeq2SeqLM.from_pretrained(repo, subfolder="int8", use_cache=True, use_merged=False)
|
| 43 |
+
inputs = tok("The weather is very nice today.", return_tensors="pt")
|
| 44 |
+
out = model.generate(**inputs, num_beams=4, max_new_tokens=64)
|
| 45 |
+
print(tok.decode(out[0], skip_special_tokens=True))
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Parity with the original PyTorch model
|
| 49 |
+
|
| 50 |
+
10 general-domain sentences, exact-string-match of generated output against
|
| 51 |
+
`MarianMTModel.generate()` on the original `Helsinki-NLP/opus-mt-en-az` checkpoint.
|
| 52 |
+
|
| 53 |
+
| Decoding | fp32 exact match | int8 exact match |
|
| 54 |
+
|---|---|---|
|
| 55 |
+
| greedy (num_beams=1) | 10/10 (100.0%) | 9/10 (90.0%) |
|
| 56 |
+
| beam=4 | 10/10 (100.0%) | 4/10 (40.0%) |
|
| 57 |
+
|
| 58 |
+
fp32 is a faithful reproduction of the original model at both decoding
|
| 59 |
+
settings. int8 dynamic quantization noticeably degrades quality on this
|
| 60 |
+
checkpoint under beam search - a spot check found real semantic drift on
|
| 61 |
+
longer sentences (not just paraphrase), e.g. for "We need to discuss the
|
| 62 |
+
budget for next quarter." the int8 beam-4 output diverged from both the
|
| 63 |
+
reference and the fp32 ONNX output. Prefer fp32 for this pair; int8 is
|
| 64 |
+
provided for size-constrained deployments where greedy decoding is used and
|
| 65 |
+
some quality loss is acceptable.
|
config.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_dropout": 0.0,
|
| 3 |
+
"activation_function": "swish",
|
| 4 |
+
"add_bias_logits": false,
|
| 5 |
+
"add_final_layer_norm": false,
|
| 6 |
+
"architectures": [
|
| 7 |
+
"MarianMTModel"
|
| 8 |
+
],
|
| 9 |
+
"attention_dropout": 0.0,
|
| 10 |
+
"bos_token_id": 0,
|
| 11 |
+
"classif_dropout": 0.0,
|
| 12 |
+
"classifier_dropout": 0.0,
|
| 13 |
+
"d_model": 512,
|
| 14 |
+
"decoder_attention_heads": 8,
|
| 15 |
+
"decoder_ffn_dim": 2048,
|
| 16 |
+
"decoder_layerdrop": 0.0,
|
| 17 |
+
"decoder_layers": 6,
|
| 18 |
+
"decoder_start_token_id": 23287,
|
| 19 |
+
"decoder_vocab_size": 23288,
|
| 20 |
+
"dropout": 0.1,
|
| 21 |
+
"dtype": "float32",
|
| 22 |
+
"encoder_attention_heads": 8,
|
| 23 |
+
"encoder_ffn_dim": 2048,
|
| 24 |
+
"encoder_layerdrop": 0.0,
|
| 25 |
+
"encoder_layers": 6,
|
| 26 |
+
"eos_token_id": 0,
|
| 27 |
+
"extra_pos_embeddings": 23288,
|
| 28 |
+
"forced_eos_token_id": 0,
|
| 29 |
+
"id2label": {
|
| 30 |
+
"0": "LABEL_0",
|
| 31 |
+
"1": "LABEL_1",
|
| 32 |
+
"2": "LABEL_2"
|
| 33 |
+
},
|
| 34 |
+
"init_std": 0.02,
|
| 35 |
+
"is_encoder_decoder": true,
|
| 36 |
+
"label2id": {
|
| 37 |
+
"LABEL_0": 0,
|
| 38 |
+
"LABEL_1": 1,
|
| 39 |
+
"LABEL_2": 2
|
| 40 |
+
},
|
| 41 |
+
"max_length": null,
|
| 42 |
+
"max_position_embeddings": 512,
|
| 43 |
+
"model_type": "marian",
|
| 44 |
+
"normalize_before": false,
|
| 45 |
+
"normalize_embedding": false,
|
| 46 |
+
"num_beams": null,
|
| 47 |
+
"num_hidden_layers": 6,
|
| 48 |
+
"pad_token_id": 23287,
|
| 49 |
+
"scale_embedding": true,
|
| 50 |
+
"share_encoder_decoder_embeddings": true,
|
| 51 |
+
"static_position_embeddings": true,
|
| 52 |
+
"transformers_version": "4.57.6",
|
| 53 |
+
"use_cache": true,
|
| 54 |
+
"vocab_size": 23288
|
| 55 |
+
}
|
decoder_model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df66ca072d83fc3fe9d1545cdf2aff14003b3069bd9bc2eb7b86ae0557de6d54
|
| 3 |
+
size 197627460
|
decoder_with_past_model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e31d3e07d0af2cde2bc2b19fabbc00b8de24a9374cc629b4a5424680820cac94
|
| 3 |
+
size 184997853
|
encoder_model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c5cda9fc48dfa9d6e7924077d604674d409c56202e845f66e4c991115fab018c
|
| 3 |
+
size 124473974
|
generation_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bad_words_ids": [
|
| 3 |
+
[
|
| 4 |
+
23287
|
| 5 |
+
]
|
| 6 |
+
],
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"decoder_start_token_id": 23287,
|
| 9 |
+
"eos_token_id": 0,
|
| 10 |
+
"forced_eos_token_id": 0,
|
| 11 |
+
"max_length": 512,
|
| 12 |
+
"num_beams": 4,
|
| 13 |
+
"pad_token_id": 23287,
|
| 14 |
+
"renormalize_logits": true,
|
| 15 |
+
"transformers_version": "4.57.6"
|
| 16 |
+
}
|
int8/decoder_model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:869df0af2f242e4d2782e49b8362ac6ee7656cbbe0bdf3fa86f30e63601b6a40
|
| 3 |
+
size 122283040
|
int8/decoder_with_past_model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6316f5b354c1e8685e9aeb31bbe0531a11f741af51ba5c0c5147099b1b4f8dca
|
| 3 |
+
size 119071097
|
int8/encoder_model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7872ef6fc986c9fa8cead3ada84511241a13ad1e343a71ec36611b1ab749455
|
| 3 |
+
size 67920512
|
source.spm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b0a4133c5eedaf9c3f880314bccc94a000251dc0a207e2df736b35273ccb68b4
|
| 3 |
+
size 451246
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"eos_token": "</s>",
|
| 3 |
+
"pad_token": "<pad>",
|
| 4 |
+
"unk_token": "<unk>"
|
| 5 |
+
}
|
target.spm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b052899ce024e382af780e7350384e6879e34fb0e7d64cd785bdde7948052197
|
| 3 |
+
size 470040
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "</s>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "<unk>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"23287": {
|
| 20 |
+
"content": "<pad>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
}
|
| 27 |
+
},
|
| 28 |
+
"clean_up_tokenization_spaces": false,
|
| 29 |
+
"eos_token": "</s>",
|
| 30 |
+
"extra_special_tokens": {},
|
| 31 |
+
"model_max_length": 512,
|
| 32 |
+
"pad_token": "<pad>",
|
| 33 |
+
"separate_vocabs": false,
|
| 34 |
+
"source_lang": "eng",
|
| 35 |
+
"sp_model_kwargs": {},
|
| 36 |
+
"target_lang": "aze",
|
| 37 |
+
"tokenizer_class": "MarianTokenizer",
|
| 38 |
+
"unk_token": "<unk>"
|
| 39 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|