opus-mt en→fi and fi→en — ONNX for Android

Source

  • Original models: Helsinki-NLP/opus-mt-en-fi and Helsinki-NLP/opus-mt-fi-en (Apache-2.0), Marian transformer models by the Helsinki-NLP research group trained on OPUS data.
  • This repository is used by the native Android app of the vibevoice-android project for sentence-by-sentence translation of speech recognition output. The app downloads the files and checks each one against a sha256 value compiled into the APK. See the original model cards for intended use, limitations and the license terms.

Files

Each direction has five files with the prefix opus-mt-en-fi. or opus-mt-fi-en.:

File What
<prefix>encoder.onnx input_ids[1,S] → the cross-attention K / V of all 6 decoder layers, cross_k / cross_v[6,1,8,S,64] (the encoder output already projected)
<prefix>decoder.onnx One decoding step: input_ids[1,1], pos[1], the previous self-attention K / V self_k / self_v[6,1,8,T,64] (T = 0 at the first step), cross_k / cross_v → logits[1,V] (with final_logits_bias) and the new K / V
<prefix>source.spm Source SentencePiece model (unchanged)
<prefix>vocab.txt The shared vocabulary from vocab.json, one piece per line, line number = id
<prefix>marian.json Decoding constants: decoder start (= pad), eos, pad, layers, heads, head size, vocabulary size, maximum positions

Exported from the transformers models with a small PyTorch wrapper (fp32, opset 17). With greedy decoding (decoder start = pad, pad suppressed, stop at </s>) the ONNX models produce exactly the same tokens as transformers generate(num_beams=1). FLEURS (100 sentences): en→fi BLEU 22.5 greedy (24.9 with beam 4), fi→en 29.4 (30.4).

Where the files apply

  • Any device with ONNX Runtime (CPU EP); about 0.12 s per sentence on a Snapdragon 8 Elite and 0.5 s on a Snapdragon 845 (2 threads).
  • English ↔ Finnish only. Tokenization must reproduce the original SentencePiece nmt_nfkc normalization and unigram segmentation.

Usage and code

To be added.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for luweigen/opus-mt-en-fi-fi-en-android

Quantized
(3)
this model