Views
No views yet
Helsinki-NLP/opus-mt-tc-big-en-tr, a Marian (en -> tr) translation model from the Helsinki-NLP OPUS-MT project.optimum-cli export onnx --model Helsinki-NLP/opus-mt-tc-big-en-tr --task text2text-generation-with-past /home/miro/tmp/claude-1000/-home-miro/849a3674-94c9-4aa5-b1f9-e596235b0a36/scratchpad/opusmt-onnx/out/en-tronnxruntime.quantization.quantize_dynamic (QUInt8 weights)../ fp32 ONNX graphs (encoder_model.onnx, decoder_model.onnx, decoder_with_past_model.onnx) + tokenizer files
./int8/ int8 dynamic-quantized ONNX graphsMarianMTModel) vs ONNX fp32 (ORTModelForSeq2SeqLM, num_beams=4, max_new_tokens=48) on 3 sentences. Match: 3/3.1from optimum.onnxruntime import ORTModelForSeq2SeqLM
2from transformers import AutoTokenizer
3
4repo = "TigreGotico/opus-mt-en-tr-onnx"
5tok = AutoTokenizer.from_pretrained(repo)
6model = ORTModelForSeq2SeqLM.from_pretrained(repo) # fp32; pass subfolder="int8" for the quantized graphs
7inputs = tok("Hello, how are you?", return_tensors="pt")
8out = model.generate(**inputs, num_beams=4, max_new_tokens=48)
9print(tok.decode(out[0], skip_special_tokens=True))