@qvac/translation-nmtcpp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +470 -0
  3. package/binding.js +1 -0
  4. package/index.d.ts +82 -0
  5. package/index.js +188 -0
  6. package/lib/error.js +65 -0
  7. package/marian.js +186 -0
  8. package/package.json +69 -0
  9. package/prebuilds/android-arm/qvac__translation-nmtcpp.bare +0 -0
  10. package/prebuilds/android-arm64/qvac__translation-nmtcpp.bare +0 -0
  11. package/prebuilds/android-ia32/qvac__translation-nmtcpp.bare +0 -0
  12. package/prebuilds/android-x64/qvac__translation-nmtcpp.bare +0 -0
  13. package/prebuilds/darwin-arm64/qvac__translation-nmtcpp.bare +0 -0
  14. package/prebuilds/darwin-arm64/qvac__translation-nmtcpp.bare.exports +3622 -0
  15. package/prebuilds/darwin-x64/qvac__translation-nmtcpp.bare +0 -0
  16. package/prebuilds/darwin-x64/qvac__translation-nmtcpp.bare.exports +3731 -0
  17. package/prebuilds/ios-arm64/qvac__translation-nmtcpp.bare +0 -0
  18. package/prebuilds/ios-arm64/qvac__translation-nmtcpp.bare.exports +3603 -0
  19. package/prebuilds/ios-arm64-simulator/qvac__translation-nmtcpp.bare +0 -0
  20. package/prebuilds/ios-arm64-simulator/qvac__translation-nmtcpp.bare.exports +3603 -0
  21. package/prebuilds/ios-x64-simulator/qvac__translation-nmtcpp.bare +0 -0
  22. package/prebuilds/ios-x64-simulator/qvac__translation-nmtcpp.bare.exports +3720 -0
  23. package/prebuilds/linux-x64/qvac__translation-nmtcpp.bare +0 -0
  24. package/prebuilds/win32-x64/qvac__translation-nmtcpp.bare +0 -0
  25. package/prebuilds/win32-x64/qvac__translation-nmtcpp.bare.exports +0 -0
  26. package/third-party/indic-processor-deps/indicnlp/INDIC_NLP_LICENCE +9 -0
  27. package/third-party/indic-processor-deps/indicnlp/index.js +11 -0
  28. package/third-party/indic-processor-deps/indicnlp/indic_detokenize.js +141 -0
  29. package/third-party/indic-processor-deps/indicnlp/indic_normalize.js +1213 -0
  30. package/third-party/indic-processor-deps/indicnlp/indic_tokenize.js +123 -0
  31. package/third-party/indic-processor-deps/indicnlp/langinfo.js +609 -0
  32. package/third-party/indic-processor-deps/indicnlp/sinhala_transliterator.js +197 -0
  33. package/third-party/indic-processor-deps/indicnlp/unicode_transliterator.js +120 -0
  34. package/third-party/indic-processor-deps/sacremoses/SACREMOSES_LICENCE +21 -0
  35. package/third-party/indic-processor-deps/sacremoses/cjk.js +202 -0
  36. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/README.txt +8 -0
  37. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.as +65 -0
  38. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.bn +65 -0
  39. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.ca +75 -0
  40. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.cs +390 -0
  41. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.de +325 -0
  42. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.el +1568 -0
  43. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.en +123 -0
  44. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.es +118 -0
  45. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.et +138 -0
  46. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.fi +138 -0
  47. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.fr +153 -0
  48. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.ga +48 -0
  49. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.gu +105 -0
  50. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.hi +113 -0
  51. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.hu +103 -0
  52. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.is +251 -0
  53. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.it +180 -0
  54. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.kn +70 -0
  55. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.lt +698 -0
  56. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.lv +100 -0
  57. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.ml +67 -0
  58. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.mni +65 -0
  59. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.mr +113 -0
  60. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.nl +115 -0
  61. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.or +101 -0
  62. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.pa +102 -0
  63. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.pl +283 -0
  64. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.pt +210 -0
  65. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.ro +38 -0
  66. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.ru +293 -0
  67. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.sk +474 -0
  68. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.sl +78 -0
  69. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.sv +97 -0
  70. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.ta +71 -0
  71. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.tdt +210 -0
  72. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.te +70 -0
  73. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.yue +53 -0
  74. package/third-party/indic-processor-deps/sacremoses/data/nonbreaking_prefixes/nonbreaking_prefix.zh +53 -0
  75. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/CJK.txt +23246 -0
  76. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/CJKSymbols.txt +1 -0
  77. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Close_Punctuation.txt +1 -0
  78. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Currency_Symbol.txt +1 -0
  79. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Han.txt +1 -0
  80. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Hangul.txt +1 -0
  81. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Hangul_Syllables.txt +1 -0
  82. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Hiragana.txt +1 -0
  83. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsAlnum-unichars-au.txt +1 -0
  84. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsAlnum.txt +1 -0
  85. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsAlpha-unichars-au.txt +1 -0
  86. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsAlpha.txt +1 -0
  87. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsLower.txt +1 -0
  88. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsN.txt +1 -0
  89. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsPf.txt +1 -0
  90. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsPi.txt +1 -0
  91. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsSc.txt +1 -0
  92. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsSo.txt +1 -0
  93. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/IsUpper.txt +1 -0
  94. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Katakana.txt +1 -0
  95. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Line_Separator.txt +1 -0
  96. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Lowercase_Letter.txt +1 -0
  97. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Number.txt +1 -0
  98. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Open_Punctuation.txt +1 -0
  99. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Punctuation.txt +1 -0
  100. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Separator.txt +1 -0
  101. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Symbol.txt +1 -0
  102. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Titlecase_Letter.txt +1 -0
  103. package/third-party/indic-processor-deps/sacremoses/data/perluniprops/Uppercase_Letter.txt +1 -0
  104. package/third-party/indic-processor-deps/sacremoses/index.js +8 -0
  105. package/third-party/indic-processor-deps/sacremoses/indic.js +76 -0
  106. package/third-party/indic-processor-deps/sacremoses/normalizer.js +264 -0
  107. package/third-party/indic-processor-deps/sacremoses/pernuliprops.js +287 -0
  108. package/third-party/indic-processor-deps/sacremoses/tokenizer.js +1217 -0
  109. package/third-party/indic-processor.js +565 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,470 @@
1
+ # Translation Addons
2
+
3
+ This library simplifies the process of running various translation models within [`QVAC`](#glossary) runtime applications. It provides a seamless interface to load, execute, and manage translation addons, offering support for multiple data sources (called data loaders).
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+ - [1. Create DataLoader](#1-create-dataloader)
10
+ - [2. Create the `args` object](#2-create-the-args-object)
11
+ - [3. Create the `config` object](#3-create-the-config-object)
12
+ - [4. Create Model Instance](#4-create-model-instance)
13
+ - [5. Load Model](#5-load-model)
14
+ - [6. Run the Model](#6-run-the-model)
15
+ - [7. Unload the Model](#7-unload-the-model)
16
+ - [Quickstart Example](#quickstart-example)
17
+ - [Model Registry](#model-registry)
18
+ - [Supported Languages](#supported-languages)
19
+ - [ModelClasses and Packages](#modelclasses-and-packages)
20
+ - [Other Examples](#other-examples)
21
+ - [Glossary](#glossary)
22
+ - [Resources](#resources)
23
+ - [License](#license)
24
+
25
+ ## Installation
26
+
27
+ ### Prerequisites
28
+
29
+ Ensure that the [`Bare`](#glossary) Runtime is installed globally on your system. If it's not already installed, you can add it using:
30
+
31
+ ```bash
32
+ npm i -g bare
33
+ ```
34
+
35
+ > **Note:** Bare version must be **1.17.3 or higher**. Verify your version with:
36
+
37
+ ```bash
38
+ bare -v
39
+ ```
40
+
41
+ Before proceeding with the installation, please generate a **classic GitHub Personal Access Token (PAT)** with the `read:packages` scope. Once generated, add the token to your environment variables using the name `NPM_TOKEN`.
42
+
43
+ ```bash
44
+ export NPM_TOKEN=your_personal_access_token
45
+ ```
46
+
47
+ Next, create a `.npmrc` file in the root of your project with the following content:
48
+
49
+ ```ini
50
+ @tetherto:registry=https://npm.pkg.github.com
51
+ //npm.pkg.github.com/:_authToken=${NPM_TOKEN}
52
+ ```
53
+
54
+ This configuration ensures secure access to GitHub Packages when installing scoped packages.
55
+
56
+ ### Installing the Package
57
+
58
+ Depending on your translation needs please choose an appropriate package from the [ModelClasses and Packages](#modelclasses-and-packages) Section and install it through `npm`. For example:
59
+
60
+ ```bash
61
+ # For translating English to Italian
62
+ npm i @qvac/translation-nmtcpp
63
+
64
+ # For translation English to Hindi
65
+ npm i @tetherto/qvac-lib-inference-addon-mlc-indictrans2-en-indic-dist-200m-q0f32
66
+ ```
67
+
68
+ ## Usage
69
+
70
+ The library provides a straightforward and intuitive workflow for translating text. Irrespective of the chosen model, the workflow remains the same:
71
+
72
+
73
+ ### 1. Create `DataLoader`
74
+
75
+ In QVAC, the [`DataLoader`](#glossary) class provides an interface for fetching model weights and other resources crucial for running AI Models. A `DataLoader` instance is required to successfully instantiate a `ModelClass`. We can create a [`HyperdriveDataLoader`](#glossary) using the following code.
76
+
77
+ ```javascript
78
+ const HyperdriveDL = require('@qvac/dl-hyperdrive')
79
+
80
+ const hdDL = new HyperdriveDL({
81
+ key: 'hyperdrive-key-hex', // (Required) The Hyperdrive key containing model files.
82
+ store: corestore // (Optional) A Corestore instance. If not provided, Hyperdrive will use an in-memory store.
83
+ })
84
+ ```
85
+
86
+ > **Note**: It is extremely important that you provide the correct `key` when using a `HyperdriveDataLoader`. A `DataLoader` with model weights and settings for an `en-it` translation can obviously not be utilized for doing a `de-en` translation. Please ensure that the `key` being used aligns with the model(package) installed and the translation requirement.
87
+
88
+ ### 2. Create the `args` object
89
+
90
+ The `args` object contains the `DataLoader` we created in the previous step and other translation parameters that control how the translation model operates, including which languages to translate between and what performance metrics to collect.
91
+
92
+ ```javascript
93
+ // Create arguments object with loader, translation parameters, and options
94
+ const args = {
95
+ // Required: Data loader instance
96
+ loader: hdDL, // or fsDL
97
+
98
+ // Required: Translation parameters
99
+ params: {
100
+ mode: 'full', // Model loading mode (full is recommended)
101
+ srcLang: 'en', // Source language (ISO 639-1 code)
102
+ dstLang: 'it' // Target language (ISO 639-1 code)
103
+ },
104
+
105
+ // Optional: Additional configuration
106
+ opts: {
107
+ stats: true // Enable performance statistics
108
+ }
109
+ }
110
+ ```
111
+
112
+ > Note: The list of supported languages for the `srcLang` and `dstLang` parameters differ from one `ModelClass` to another. Please refer to the [Supported Languages](#supported-languages) section for more details.
113
+
114
+ ### 3. Create the `config` object
115
+
116
+ This config expresses your “how to generate” policy for a run: it balances determinism (greedy/beam) and diversity (sampling) while enforcing simple constraints (length, repetition).
117
+
118
+ ```javascript
119
+ // Define files needed by the model
120
+ const config = {
121
+ // Runtime decoding controls (can also be set later via model.setConfig)
122
+ beamsize: 4, // Beam search width (>=1). 1 disables beam search
123
+ lengthpenalty: 0.6, // Length normalization strength (>=0)
124
+ maxlength: 128, // Maximum generated tokens (>0)
125
+
126
+ // Repetition and constraints
127
+ repetitionpenalty: 1.2, // Penalize previously generated tokens (0..2)
128
+ norepeatngramsize: 2, // Disallow repeating n-grams of this size (0..10)
129
+
130
+ // Sampling controls
131
+ temperature: 0.8, //[0..2]
132
+ topk: 40, // Keep top-K logits [0..vocab_size]
133
+ topp: 0.9 // Nucleus sampling threshold (0< p <=1)
134
+ }
135
+ ```
136
+
137
+ ### 4. Create Model Instance
138
+
139
+ We first import the `ModelClass` from the installed package, then we instantiate the model by passing it the `args` and `config` objects.
140
+
141
+ ```javascript
142
+ const { ModelClass } = require('installed/package/name')
143
+ const model = new ModelClass(args, config)
144
+ ```
145
+
146
+ For example:
147
+
148
+ ```javascript
149
+ const { MLCMarianOpusQ4F16 } = require('@qvac/translation-nmtcpp-opus-q4f16')
150
+ const model = new MLCMarianOpusQ4F16(args, config)
151
+ ```
152
+
153
+ ### 5. Load Model
154
+
155
+ ```javascript
156
+ try {
157
+ // Basic usage
158
+ await model.load()
159
+ } catch (error) {
160
+ console.error('Failed to load model:', error)
161
+ }
162
+ ```
163
+
164
+ ### 6. Run the Model
165
+
166
+ We can perform inference on the input text using the `run()` method. This method returns a [`QVACResponse`](#glossary) object.
167
+
168
+ ```javascript
169
+ try {
170
+ // Execute translation on input text
171
+ const response = await model.run('Hello world! Welcome to the internet of peers!')
172
+
173
+ // Process streamed output using callback
174
+ await response
175
+ .onUpdate(outputChunk => {
176
+ // Handle each new piece of translated text
177
+ console.log(outputChunk)
178
+ })
179
+ .await() // Wait for translation to complete
180
+
181
+ // Access performance statistics (if enabled with opts.stats)
182
+ if (response.stats) {
183
+ console.log('Translation completed in:', response.stats.totalTime, 'ms')
184
+ }
185
+ } catch (error) {
186
+ console.error('Translation failed:', error)
187
+ }
188
+ ```
189
+
190
+ ### 7. Unload the Model
191
+
192
+ ```javascript
193
+ // Always unload the model when finished to free memory
194
+ try {
195
+ await model.unload()
196
+ } catch (error) {
197
+ console.error('Failed to unload model:', error)
198
+ }
199
+ ```
200
+
201
+ ### Additional Features
202
+
203
+ - **Pause and Resume:** Translation can be paused and resumed (see [`examples/pause.example.js`](examples/pause.example.js))
204
+ - **Progress Tracking:** Monitor loading progress with a callback function
205
+ - **Performance Stats:** Measure inference time with the `stats` option
206
+
207
+ For a complete working example that brings all these steps together, see the [Quickstart Example](#quickstart-example) below.
208
+
209
+ ## Quickstart Example
210
+
211
+ Follow these steps to run the Quickstart Example:
212
+
213
+ ### 1. Create a New Project
214
+
215
+ ```bash
216
+ mkdir translation-example
217
+ cd translation-example
218
+ npm init -y
219
+ ```
220
+
221
+ ### 2. Install Required Dependencies
222
+
223
+ ```bash
224
+ npm i @qvac/translation-nmtcpp-opus-q4f16 @qvac/dl-hyperdrive
225
+ ```
226
+
227
+ ### 3. Create `example.js` and paste the following code into it
228
+
229
+ ```bash
230
+ touch example.js
231
+ ```
232
+
233
+ ```javascript
234
+ // example.js
235
+
236
+ 'use strict'
237
+
238
+ // Note: This import will depend on the addon package installed
239
+ const TranslationNmtcpp = require('..')
240
+ const HyperdriveDL = require('@qvac/dl-hyperdrive')
241
+
242
+ const text = 'La traduzione automatica ha rivoluzionato il modo in cui comunichiamo attraverso le barriere linguistiche nel mondo digitale moderno.'
243
+
244
+ async function main () {
245
+ // 1. Create `DataLoader`
246
+ const hdDL = new HyperdriveDL({
247
+ // The hyperdrive key for en-it translation model weights and config
248
+ key: 'hd://9ef58f31c20d5556722e0b58a5d262fd89801daf2e6cb28e3f21ac6e9228088f'
249
+ })
250
+
251
+ // 2. Create the `args` object
252
+ const args = {
253
+ loader: hdDL,
254
+ params: { mode: 'full', dstLang: 'en', srcLang: 'it' },
255
+ diskPath: './models',
256
+ modelName: 'model.bin',
257
+ }
258
+
259
+ // 3. Optional : Create config object
260
+ const config = {beamsize : 4}
261
+
262
+ // 4. Create Model Instance
263
+ const model = new TranslationNmtcpp(args, config)
264
+
265
+ // 5. Load model
266
+ await model.load()
267
+
268
+ try {
269
+ // 6. Run the Model
270
+ const response = await model.run(text)
271
+
272
+ await response
273
+ .onUpdate(data => {
274
+ console.log(data)
275
+ })
276
+ .await()
277
+
278
+ console.log('translation finished!')
279
+ } finally {
280
+ // 7. Unload the model
281
+ await model.unload()
282
+
283
+ // Close the DataLoader
284
+ await hdDL.close()
285
+ }
286
+ }
287
+
288
+
289
+ main().catch(console.error)
290
+ ```
291
+
292
+ ### 4. Run the Example
293
+
294
+ ```bash
295
+ bare example.js
296
+ ```
297
+
298
+ You should see this output on successful execution
299
+
300
+ ```bash
301
+ params_shard_0.bin has these many parameter records: 1
302
+ params_shard_1.bin has these many parameter records: 19
303
+ params_shard_2.bin has these many parameter records: 1
304
+ params_shard_3.bin has these many parameter records: 336
305
+ Ciao a tutti!
306
+ translation finished!
307
+ ```
308
+
309
+ ## Model Registry
310
+
311
+ The **Hyperbee key** for the model registry is:
312
+
313
+ ```
314
+ 7504626aaa534ac55d91b4b3067504774ae1457b03ddfbd86d817dd8cfbca8c8
315
+ ```
316
+
317
+ Below is the section of the registry dedicated to **translation tasks**. Each entry maps a specific model and language pair (left-hand side) to the corresponding **Hyperdrive key** (right-hand side), which stores the model's weights and configuration settings.
318
+
319
+ ```javascript
320
+ "translation:marian:opus-ggml:::q0f32:1.0.0:en-it": "9ef58f31c20d5556722e0b58a5d262fd89801daf2e6cb28e3f21ac6e9228088f"
321
+ "translation:marian:opus-ggml:::q0f32:1.0.0:en-de": "7b1d16235cd4dd9cc2c58d1fc1c41d65159aa4d2337169c6243a5bc8bf49689b"
322
+ "translation:marian:opus-ggml:::q0f32:1.0.0:en-es": "8aa823831cc55f5c1cba2c046e98b53a0d32376267ca73d653294b8b114459a2"
323
+ "translation:marian:opus-ggml:::q0f32:1.0.0:de-en": "b4d1ab62f885d9814acfddc565761b607bf86a307c38430ec1dabfe1a92532af"
324
+ "translation:marian:opus-ggml:::q0f32:1.0.0:de-es": "f432152db25ebd86fa0e48cd12f27e67e5c052c9af99c7662939dc1d84792c3e"
325
+ "translation:marian:opus-ggml:::q0f32:1.0.0:de-it": "06d26bdc965d548c156885ed105f8150618aaa11712579158e81f1d49735aaf6"
326
+ "translation:marian:opus-ggml:::q0f32:1.0.0:es-de": "ff6a02096c3e2f4e1aa7e4a75cb37aa851bc924c9d4af2b30b26431f1cb9d156"
327
+ "translation:marian:opus-ggml:::q0f32:1.0.0:es-en": "b96cf6c79119578b9f9a2206b19ce9686e95f31949ce62b24aef83fbdf4b0b08"
328
+ "translation:marian:opus-ggml:::q0f32:1.0.0:es-it": "b04ba8638fea5adff061aba9ccc671936ab8f7459346461f6c2010d4c7413254"
329
+ "translation:marian:opus-ggml:::q0f32:1.0.0:it-de": "438cbda449f1ac258a2fdea55cfd1f9f83dfb0ea20103c1e5113906081eec4f5"
330
+ "translation:marian:opus-ggml:::q0f32:1.0.0:it-en": "68778c8375fbb1e7f5c20b4e6087131206e9ddba1872655e20931b7e08fe3954"
331
+ "translation:marian:opus-ggml:::q0f32:1.0.0:it-es": "1b78d8309f80fcda61d0291ed5dc755e10e46b39d7e7484083a3c6d20b86c679"
332
+ "translation:ggml-indictrans:full:2:1B:q0f32:1.0.0:hi-en": "d46a9192b479fb5c982e60b84ae25bb5a61f3f090a41d45d5c5dda597973a9dd"
333
+ "translation:ggml-indictrans:full:2:1B:q0f32:1.0.0:en-hi": "61d1eb542956914ad2eadaf405b76a4dcc327fd6ccf1191bb17cd102a642691e"
334
+ "translation:ggml-indictrans:full:2:1B:q0f32:1.0.0:hi-hi": "cd8e441d1da68602e19a92f5d1ee794852e802ee234a638df2976bb1bc2493ad"
335
+ "translation:ggml-indictrans:dist:2:200M:q0f32:1.0.0:en-hi": "268c2e9b2a3420632e4b6649e32822f42d5dfbda4c7e96daec5b629ed20f99f7"
336
+ "translation:ggml-indictrans:dist:2:200M:q0f32:1.0.0:hi-en": "dfea395ffe1cb6d259029e5c81c290f8828981987855e23e7b66fd7c705901eb"
337
+ "translation:ggml-indictrans:dist:2:320M:q0f32:1.0.0:hi-hi": "9a66da960931c449b41e3315d9aea4d3925f2cda024e8a4c139b64d0a539ed41"
338
+ "translation:ggml-indictrans:full:2:1B:q0f16:1.0.0:en-hi": "be5bff40a002c627a992d096861c0e9b0be6ac7770300cee0bb09ccda87404cb"
339
+ "translation:ggml-indictrans:full:2:200M:q0f16:1.0.0:en-hi": "42ba45bbf4c24ff743890bc0cc65d8c23c91a14d26f760b3f814df76be8e036f"
340
+ "translation:ggml-indictrans:full:2:1B:q0f16:1.0.0:hi-en": "d06c487c56a36bb153d9d33bc1085bc90561d2a8dad5cd5701db782e1540a343"
341
+ "translation:ggml-indictrans:full:2:200M:q0f16:1.0.0:hi-en": "2e35d09ba69dd2b692c668862fdee43fa941859690b1e17aecc96c73474521b9"
342
+ "translation:ggml-indictrans:full:2:1B:q0f16:1.0.0:hi-hi": "f4edc8b072c34840c08aab2c8abdc288aa2dff8c2ed76fc96ad6604e322a038f"
343
+ "translation:ggml-indictrans:full:2:320M:q0f16:1.0.0:hi-hi": "1bb2ad463127325ca8daa801ec89ae6a2983ddeb90c5461a965e65fa295e3655"
344
+ "translation:ggml-indictrans:full:2:1B:q4_0:1.0.0:en-hi": "9fb5b7338504b24df0f3dd9ae8a1c280c6f00fd7f3295cca8f884514c5fa9713"
345
+ "translation:ggml-indictrans:full:2:200M:q4_0:1.0.0:en-hi": "8336d23073b2fd99723bf17d65ddc7b54b8ee886d6627659ba95c7a8fb932dc8"
346
+ "translation:ggml-indictrans:full:2:1B:q4_0:1.0.0:hi-en": "1fd66a6862776a92c7fae1962a1f07a5bc7369fb8be3dd9b76adf7c71855af7f"
347
+ "translation:ggml-indictrans:full:2:200M:q4_0:1.0.0:hi-en": "ba7db8c0dbcb6fc4276f86a27e3b9dd0f5e90b79f550a1666757f6074e2a4331"
348
+ "translation:ggml-indictrans:full:2:1B:q4_0:1.0.0:hi-hi": "0f03a3a06bc7006deb0da42643585dc0da49b897ba49e449ec67013ba4464e8a"
349
+ "translation:ggml-indictrans:full:2:320M:q4_0:1.0.0:hi-hi": "6cba73db82148a228bfdc586e2e565db6e6beb476575de3602d927ecb08b1a70"
350
+ ```
351
+
352
+ Each key in this list follows the general pattern:
353
+
354
+ ```
355
+ <model_family>:<version>:<size>:<quantization>:<release>:<source-lang>-<target-lang>
356
+ ```
357
+
358
+ ## Supported Languages
359
+
360
+ Here is the list of languages supported for the Marian models:
361
+
362
+ <table>
363
+ <tbody>
364
+ <tr><td>English (en)</td></tr>
365
+ <tr><td>German (de)</td></tr>
366
+ <tr><td>Italian (it)</td></tr>
367
+ <tr><td>Spanish (es)</td></tr>
368
+ </tbody>
369
+ </table>
370
+
371
+ Here is the list of languages supported by the IndicTrans2 models:
372
+
373
+ <table>
374
+ <tbody>
375
+ <tr>
376
+ <td>Assamese (asm_Beng)</td>
377
+ <td>Kashmiri (Arabic) (kas_Arab)</td>
378
+ <td>Punjabi (pan_Guru)</td>
379
+ </tr>
380
+ <tr>
381
+ <td>Bengali (ben_Beng)</td>
382
+ <td>Kashmiri (Devanagari) (kas_Deva)</td>
383
+ <td>Sanskrit (san_Deva)</td>
384
+ </tr>
385
+ <tr>
386
+ <td>Bodo (brx_Deva)</td>
387
+ <td>Maithili (mai_Deva)</td>
388
+ <td>Santali (sat_Olck)</td>
389
+ </tr>
390
+ <tr>
391
+ <td>Dogri (doi_Deva)</td>
392
+ <td>Malayalam (mal_Mlym)</td>
393
+ <td>Sindhi (Arabic) (snd_Arab)</td>
394
+ </tr>
395
+ <tr>
396
+ <td>English (eng_Latn)</td>
397
+ <td>Marathi (mar_Deva)</td>
398
+ <td>Sindhi (Devanagari) (snd_Deva)</td>
399
+ </tr>
400
+ <tr>
401
+ <td>Konkani (gom_Deva)</td>
402
+ <td>Manipuri (Bengali) (mni_Beng)</td>
403
+ <td>Tamil (tam_Taml)</td>
404
+ </tr>
405
+ <tr>
406
+ <td>Gujarati (guj_Gujr)</td>
407
+ <td>Manipuri (Meitei) (mni_Mtei)</td>
408
+ <td>Telugu (tel_Telu)</td>
409
+ </tr>
410
+ <tr>
411
+ <td>Hindi (hin_Deva)</td>
412
+ <td>Nepali (npi_Deva)</td>
413
+ <td>Urdu (urd_Arab)</td>
414
+ </tr>
415
+ <tr>
416
+ <td>Kannada (kan_Knda)</td>
417
+ <td>Odia (ory_Orya)</td>
418
+ <td></td>
419
+ </tr>
420
+ </tbody>
421
+ </table>
422
+
423
+ ## Benchmarking
424
+
425
+ We conduct comprehensive benchmarking of our translation models to evaluate their performance across different language pairs and metrics. Our benchmarking suite measures translation quality using BLEU and COMET scores, as well as performance metrics including load times and inference speeds.
426
+
427
+ ### Benchmark Results
428
+
429
+ For detailed benchmark results across all supported language pairs and model configurations, see our [Benchmark Results Summary](benchmarks/results/results_summary.md).
430
+
431
+ The benchmarking covers:
432
+
433
+ - **Translation Quality**: BLEU and COMET scores for accuracy assessment
434
+ - **Performance Metrics**: Model loading times and inference speeds
435
+ - **Language Pairs**: All supported source-target language combinations
436
+ - **Model Variants**: Different quantization levels and model sizes
437
+
438
+ Results are updated regularly as new model versions are released.
439
+
440
+ ## Other Examples
441
+
442
+ - [Filesystem Data Loader](examples/example.fs.js): Demonstrates using the library with the Filesystem Data Loader for Marian model inference.
443
+ - [Pause Example](examples/pause.example.js): Demonstrates pausing and resuming the addon during inference.
444
+ - [IndicTrans2 en-hi Example](examples/indictrans.js): Demonstrates how to use the library for English-to-Hindi translation with the IndicTrans2 model, including setup, loading model weights, and running inference.
445
+
446
+ ## Glossary
447
+
448
+ - **Bare** – Lightweight, modular JavaScript runtime for desktop and mobile. [Docs](https://docs.pears.com/bare-reference/overview)
449
+ - **Hyperdrive** – Secure, real-time distributed filesystem enabling P2P file sharing. [Docs](https://docs.pears.com/building-blocks/hyperdrive)
450
+ - **Hyperbee** – Decentralized B-tree built on Hypercores, with a key-value API. [Docs](https://docs.pears.com/building-blocks/hyperbee)
451
+ - **Corestore** – Factory for managing named collections of Hypercores. [Docs](https://docs.pears.com/helpers/corestore)
452
+ - **QVAC** – Open-source SDK for building decentralized AI applications.
453
+ - **QVACResponse** – The response object used by the QVAC API. [GitHub](https://github.com/tetherto/qvac-lib-response)
454
+ - **DataLoader** – Abstraction for fetching model weights and resources.
455
+ Implementations include:
456
+ - **`HyperdriveDL`** – Loads from a Hyperdrive instance [GitHub](https://github.com/tetherto/qvac-lib-dl-hyperdrive)
457
+ - **`fsDL`** – Loads from the local filesystem [GitHub](https://github.com/tetherto/qvac-lib-dl-filesystem)
458
+
459
+ ## Resources
460
+
461
+ - **Pear Platform** – Decentralized platform for deploying apps. [pears.com](https://pears.com/)
462
+ - **Bare Runtime Docs** – For running QVAC apps in a lightweight environment. [docs.pears.com/bare](https://docs.pears.com/bare-reference/overview)
463
+ - **IndicTrans2 Model** – Pretrained multilingual translation models. [AI4Bharat/IndicTrans2](https://github.com/AI4Bharat/IndicTrans2)
464
+ - **Translation App Example** – QVAC-based translation application. [qvac-examples/translation-app](https://github.com/tetherto/qvac-examples/tree/main/translation-app)
465
+
466
+ ## License
467
+
468
+ This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details.<br>
469
+ For any questions o issues, please open an issue on the GitHub repository.
470
+ Test mobile job visibility
package/binding.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require.addon()