qaihm-bot commited on
Commit
d64d11a
·
verified ·
1 Parent(s): 18d21f2

See https://github.com/quic/ai-hub-models/releases/v0.45.0 for changelog.

.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
+ OpusMT-En-Zh_OpusMTDecoder_float.dlc filter=lfs diff=lfs merge=lfs -text
37
+ OpusMT-En-Zh_OpusMTEncoder_float.dlc filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1 @@
 
 
1
+ The license of the original trained model can be found at https://github.com/Helsinki-NLP/Opus-MT/blob/master/LICENSE.
OpusMT-En-Zh_OpusMTDecoder_float.dlc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:437a2d7cbed99f1593cf3cd1674674eaf272a80497c2f95e21711f5925d133ac
3
+ size 178309004
OpusMT-En-Zh_OpusMTDecoder_float.onnx.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d713a3a2aa9dc837f10bebff4d087a35631782f19c11622e9f29f7745821a50
3
+ size 329379606
OpusMT-En-Zh_OpusMTDecoder_float.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9763f695dbebf16ad0bef627b51b65e4acb728a89e0131b24780fc2794710efd
3
+ size 223058404
OpusMT-En-Zh_OpusMTEncoder_float.dlc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:884760980d96a4838ac098d7f829d5ccc05f93b8a302028cbc5dede0520c0c3c
3
+ size 111199780
OpusMT-En-Zh_OpusMTEncoder_float.onnx.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0588a526bbd6171e2d64b0d95d6dd9d6493ca04dfeafcba9318d3d9ac7b549f8
3
+ size 206708165
OpusMT-En-Zh_OpusMTEncoder_float.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec81a70438502ca38f0a7a300af1c467e1e10168f7da73d2a9845e79d1836e23
3
+ size 222233484
README.md ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: other
4
+ tags:
5
+ - foundation
6
+ - android
7
+ pipeline_tag: text-generation
8
+
9
+ ---
10
+
11
+ ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_en_zh/web-assets/model_demo.png)
12
+
13
+ # OpusMT-En-Zh: Optimized for Mobile Deployment
14
+ ## OpusMT English to Chinese neural machine translation model based on MarianMT transformer architecture
15
+
16
+
17
+ OpusMT English to Chinese translation model is a state-of-the-art neural machine translation system designed for translating English text into Chinese. This model is based on the Marian transformer architecture and has been optimized for edge inference by splitting into encoder and decoder components with modified attention mechanisms. It exhibits robust performance for real-world translation tasks, making it highly reliable for practical applications. The model supports input sequences up to 256 tokens and can generate Chinese translations with high accuracy.
18
+
19
+ This model is an implementation of OpusMT-En-Zh found [here](https://github.com/Helsinki-NLP/Opus-MT).
20
+
21
+
22
+ This repository provides scripts to run OpusMT-En-Zh on Qualcomm® devices.
23
+ More details on model performance across various devices, can be found
24
+ [here](https://aihub.qualcomm.com/models/opus_mt_en_zh).
25
+
26
+
27
+
28
+ ### Model Details
29
+
30
+ - **Model Type:** Model_use_case.text_generation
31
+ - **Model Stats:**
32
+ - Model checkpoint: Helsinki-NLP/opus-mt-en-zh
33
+ - Input resolution: 256 tokens (English text)
34
+ - Max input sequence length: 256 tokens
35
+ - Max output sequence length: 256 tokens
36
+ - Number of parameters (OpusMTEncoder): ~74M
37
+ - Model size (OpusMTEncoder) (float): ~280 MB
38
+ - Number of parameters (OpusMTDecoder): ~74M
39
+ - Model size (OpusMTDecoder) (float): ~280 MB
40
+ - Number of encoder layers: 6
41
+ - Number of decoder layers: 6
42
+ - Attention heads: 8
43
+ - Hidden dimension: 512
44
+
45
+ | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
46
+ |---|---|---|---|---|---|---|---|---|
47
+ | OpusMTEncoder | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 12.799 ms | 6 - 181 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
48
+ | OpusMTEncoder | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 12.547 ms | 0 - 139 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
49
+ | OpusMTEncoder | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 5.02 ms | 6 - 342 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
50
+ | OpusMTEncoder | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 4.829 ms | 0 - 172 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
51
+ | OpusMTEncoder | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 3.654 ms | 0 - 2 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
52
+ | OpusMTEncoder | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 3.529 ms | 0 - 249 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
53
+ | OpusMTEncoder | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 5.715 ms | 13 - 15 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
54
+ | OpusMTEncoder | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 4.849 ms | 6 - 181 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
55
+ | OpusMTEncoder | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 4.554 ms | 0 - 140 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
56
+ | OpusMTEncoder | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 12.799 ms | 6 - 181 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
57
+ | OpusMTEncoder | float | SA7255P ADP | Qualcomm® SA7255P | QNN_DLC | 12.547 ms | 0 - 139 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
58
+ | OpusMTEncoder | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 5.541 ms | 6 - 180 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
59
+ | OpusMTEncoder | float | SA8295P ADP | Qualcomm® SA8295P | QNN_DLC | 5.235 ms | 0 - 139 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
60
+ | OpusMTEncoder | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 4.849 ms | 6 - 181 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
61
+ | OpusMTEncoder | float | SA8775P ADP | Qualcomm® SA8775P | QNN_DLC | 4.554 ms | 0 - 140 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
62
+ | OpusMTEncoder | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 2.654 ms | 0 - 340 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
63
+ | OpusMTEncoder | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 2.561 ms | 0 - 175 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
64
+ | OpusMTEncoder | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 4.132 ms | 15 - 327 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
65
+ | OpusMTEncoder | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 2.247 ms | 0 - 349 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
66
+ | OpusMTEncoder | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | QNN_DLC | 2.128 ms | 0 - 143 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
67
+ | OpusMTEncoder | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 3.558 ms | 0 - 335 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
68
+ | OpusMTEncoder | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 1.773 ms | 0 - 316 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
69
+ | OpusMTEncoder | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | QNN_DLC | 1.622 ms | 0 - 145 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
70
+ | OpusMTEncoder | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 2.862 ms | 0 - 299 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
71
+ | OpusMTEncoder | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 3.871 ms | 0 - 0 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
72
+ | OpusMTEncoder | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 5.79 ms | 108 - 108 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
73
+ | OpusMTDecoder | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 6.378 ms | 0 - 424 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
74
+ | OpusMTDecoder | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 5.378 ms | 6 - 241 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
75
+ | OpusMTDecoder | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 4.72 ms | 0 - 426 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
76
+ | OpusMTDecoder | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 4.11 ms | 6 - 249 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
77
+ | OpusMTDecoder | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 3.491 ms | 0 - 3 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
78
+ | OpusMTDecoder | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 2.89 ms | 2 - 346 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
79
+ | OpusMTDecoder | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 3.892 ms | 12 - 14 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
80
+ | OpusMTDecoder | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 11.184 ms | 0 - 292 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
81
+ | OpusMTDecoder | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 3.504 ms | 6 - 243 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
82
+ | OpusMTDecoder | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 6.378 ms | 0 - 424 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
83
+ | OpusMTDecoder | float | SA7255P ADP | Qualcomm® SA7255P | QNN_DLC | 5.378 ms | 6 - 241 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
84
+ | OpusMTDecoder | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 4.795 ms | 0 - 285 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
85
+ | OpusMTDecoder | float | SA8295P ADP | Qualcomm® SA8295P | QNN_DLC | 4.061 ms | 6 - 234 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
86
+ | OpusMTDecoder | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 11.184 ms | 0 - 292 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
87
+ | OpusMTDecoder | float | SA8775P ADP | Qualcomm® SA8775P | QNN_DLC | 3.504 ms | 6 - 243 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
88
+ | OpusMTDecoder | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 2.62 ms | 0 - 573 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
89
+ | OpusMTDecoder | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 2.196 ms | 0 - 259 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
90
+ | OpusMTDecoder | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 2.913 ms | 0 - 415 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
91
+ | OpusMTDecoder | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 2.314 ms | 14 - 503 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
92
+ | OpusMTDecoder | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | QNN_DLC | 1.959 ms | 0 - 236 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
93
+ | OpusMTDecoder | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 2.579 ms | 0 - 442 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
94
+ | OpusMTDecoder | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 2.164 ms | 0 - 434 MB | NPU | [OpusMT-En-Zh.tflite](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.tflite) |
95
+ | OpusMTDecoder | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | QNN_DLC | 1.888 ms | 0 - 243 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
96
+ | OpusMTDecoder | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 2.447 ms | 1 - 405 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
97
+ | OpusMTDecoder | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 2.736 ms | 6 - 6 MB | NPU | [OpusMT-En-Zh.dlc](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.dlc) |
98
+ | OpusMTDecoder | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 3.166 ms | 161 - 161 MB | NPU | [OpusMT-En-Zh.onnx.zip](https://huggingface.co/qualcomm/OpusMT-En-Zh/blob/main/OpusMT-En-Zh.onnx.zip) |
99
+
100
+
101
+
102
+
103
+ ## Installation
104
+
105
+
106
+ Install the package via pip:
107
+ ```bash
108
+ # NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
109
+ pip install "qai-hub-models[opus-mt-en-zh]"
110
+ ```
111
+
112
+
113
+ ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
114
+
115
+ Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
116
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
117
+
118
+ With this API token, you can configure your client to run models on the cloud
119
+ hosted devices.
120
+ ```bash
121
+ qai-hub configure --api_token API_TOKEN
122
+ ```
123
+ Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
124
+
125
+
126
+
127
+ ## Demo off target
128
+
129
+ The package contains a simple end-to-end demo that downloads pre-trained
130
+ weights and runs this model on a sample input.
131
+
132
+ ```bash
133
+ python -m qai_hub_models.models.opus_mt_en_zh.demo
134
+ ```
135
+
136
+ The above demo runs a reference implementation of pre-processing, model
137
+ inference, and post processing.
138
+
139
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
140
+ environment, please add the following to your cell (instead of the above).
141
+ ```
142
+ %run -m qai_hub_models.models.opus_mt_en_zh.demo
143
+ ```
144
+
145
+
146
+ ### Run model on a cloud-hosted device
147
+
148
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
149
+ device. This script does the following:
150
+ * Performance check on-device on a cloud-hosted device
151
+ * Downloads compiled assets that can be deployed on-device for Android.
152
+ * Accuracy check between PyTorch and on-device outputs.
153
+
154
+ ```bash
155
+ python -m qai_hub_models.models.opus_mt_en_zh.export
156
+ ```
157
+
158
+
159
+
160
+ ## How does this work?
161
+
162
+ This [export script](https://aihub.qualcomm.com/models/opus_mt_en_zh/qai_hub_models/models/OpusMT-En-Zh/export.py)
163
+ leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
164
+ on-device. Lets go through each step below in detail:
165
+
166
+ Step 1: **Compile model for on-device deployment**
167
+
168
+ To compile a PyTorch model for on-device deployment, we first trace the model
169
+ in memory using the `jit.trace` and then call the `submit_compile_job` API.
170
+
171
+ ```python
172
+ import torch
173
+
174
+ import qai_hub as hub
175
+ from qai_hub_models.models.opus_mt_en_zh import Model
176
+
177
+ # Load the model
178
+ torch_model = Model.from_pretrained()
179
+
180
+ # Device
181
+ device = hub.Device("Samsung Galaxy S25")
182
+
183
+ # Trace model
184
+ input_shape = torch_model.get_input_spec()
185
+ sample_inputs = torch_model.sample_inputs()
186
+
187
+ pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
188
+
189
+ # Compile model on a specific device
190
+ compile_job = hub.submit_compile_job(
191
+ model=pt_model,
192
+ device=device,
193
+ input_specs=torch_model.get_input_spec(),
194
+ )
195
+
196
+ # Get target model to run on-device
197
+ target_model = compile_job.get_target_model()
198
+
199
+ ```
200
+
201
+
202
+ Step 2: **Performance profiling on cloud-hosted device**
203
+
204
+ After compiling models from step 1. Models can be profiled model on-device using the
205
+ `target_model`. Note that this scripts runs the model on a device automatically
206
+ provisioned in the cloud. Once the job is submitted, you can navigate to a
207
+ provided job URL to view a variety of on-device performance metrics.
208
+ ```python
209
+ profile_job = hub.submit_profile_job(
210
+ model=target_model,
211
+ device=device,
212
+ )
213
+
214
+ ```
215
+
216
+ Step 3: **Verify on-device accuracy**
217
+
218
+ To verify the accuracy of the model on-device, you can run on-device inference
219
+ on sample input data on the same cloud hosted device.
220
+ ```python
221
+ input_data = torch_model.sample_inputs()
222
+ inference_job = hub.submit_inference_job(
223
+ model=target_model,
224
+ device=device,
225
+ inputs=input_data,
226
+ )
227
+ on_device_output = inference_job.download_output_data()
228
+
229
+ ```
230
+ With the output of the model, you can compute like PSNR, relative errors or
231
+ spot check the output with expected output.
232
+
233
+ **Note**: This on-device profiling and inference requires access to Qualcomm®
234
+ AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
235
+
236
+
237
+
238
+
239
+ ## Deploying compiled model to Android
240
+
241
+
242
+ The models can be deployed using multiple runtimes:
243
+ - TensorFlow Lite (`.tflite` export): [This
244
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
245
+ guide to deploy the .tflite model in an Android application.
246
+
247
+
248
+ - QNN (`.so` export ): This [sample
249
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
250
+ provides instructions on how to use the `.so` shared library in an Android application.
251
+
252
+
253
+ ## View on Qualcomm® AI Hub
254
+ Get more details on OpusMT-En-Zh's performance across various devices [here](https://aihub.qualcomm.com/models/opus_mt_en_zh).
255
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
256
+
257
+
258
+ ## License
259
+ * The license for the original implementation of OpusMT-En-Zh can be found
260
+ [here](https://github.com/Helsinki-NLP/Opus-MT/blob/master/LICENSE).
261
+
262
+
263
+
264
+ ## References
265
+ * [OPUS-MT – Building open translation services for the World](https://aclanthology.org/2020.eamt-1.61/)
266
+ * [Source Model Implementation](https://github.com/Helsinki-NLP/Opus-MT)
267
+
268
+
269
+
270
+ ## Community
271
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
272
+ * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
273
+
274
+
tool-versions.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ tool_versions:
2
+ onnx:
3
+ qairt: 2.37.1.250807093845_124904
4
+ onnx_runtime: 1.23.0