Update Readme with quick start
#1
by axay - opened
README.md
CHANGED
|
@@ -61,6 +61,103 @@ The models are built using the Marian/Bergamot framework and are designed to pro
|
|
| 61 |
| Dutch | nl | ##NL |
|
| 62 |
| Swedish | sv | ##SV |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
# Model Details
|
| 65 |
|
| 66 |
## Architecture
|
|
|
|
| 61 |
| Dutch | nl | ##NL |
|
| 62 |
| Swedish | sv | ##SV |
|
| 63 |
|
| 64 |
+
# Quick Start (QVAC SDK)
|
| 65 |
+
|
| 66 |
+
The INTGEMM packs run out of the box with the [QVAC SDK](https://docs.qvac.tether.io/) using its built-in Bergamot NMT engine. The SDK runs on Node.js, Bare, and Expo, with native backends (Metal on macOS, Vulkan on Windows/Linux).
|
| 67 |
+
|
| 68 |
+
**Requirements:** Node.js >= 22.17.
|
| 69 |
+
|
| 70 |
+
## 1. Download the model
|
| 71 |
+
|
| 72 |
+
Grab the Base INTGEMM packs (both directions) with the HuggingFace CLI:
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
pip install -U "huggingface_hub[cli]"
|
| 76 |
+
|
| 77 |
+
huggingface-cli download <your-org>/TranslatePsy-Euro \
|
| 78 |
+
--include "en-xx/Base/intgemm/*" "xx-en/Base/intgemm/*" \
|
| 79 |
+
--local-dir ./TranslatePsy-Euro
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
This gives you:
|
| 83 |
+
|
| 84 |
+
```text
|
| 85 |
+
TranslatePsy-Euro/
|
| 86 |
+
en-xx/Base/intgemm/{model.intgemm.alphas.bin, vocab.spm} # English -> European
|
| 87 |
+
xx-en/Base/intgemm/{model.intgemm.alphas.bin, vocab.spm} # European -> English
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
Swap `Base` for `BaseMemory` or `Tiny` to trade quality for size, or drop `--include` to fetch every variant.
|
| 91 |
+
|
| 92 |
+
## 2. Install the SDK
|
| 93 |
+
|
| 94 |
+
```bash
|
| 95 |
+
npm init -y && npm pkg set type=module
|
| 96 |
+
npm install @qvac/sdk
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
## 3. Translate
|
| 100 |
+
|
| 101 |
+
Save as `quickstart.mjs`:
|
| 102 |
+
|
| 103 |
+
```js
|
| 104 |
+
import path from "node:path";
|
| 105 |
+
import { loadModel, translate, unloadModel } from "@qvac/sdk";
|
| 106 |
+
|
| 107 |
+
const ROOT = "./TranslatePsy-Euro";
|
| 108 |
+
|
| 109 |
+
// direction: "en-xx" (English -> European) or "xx-en" (European -> English)
|
| 110 |
+
function load(direction, from, to) {
|
| 111 |
+
const dir = path.join(ROOT, direction, "Base", "intgemm");
|
| 112 |
+
return loadModel({
|
| 113 |
+
modelSrc: path.join(dir, "model.intgemm.alphas.bin"),
|
| 114 |
+
modelType: "nmt",
|
| 115 |
+
modelConfig: {
|
| 116 |
+
engine: "Bergamot",
|
| 117 |
+
from,
|
| 118 |
+
to,
|
| 119 |
+
srcVocabSrc: path.join(dir, "vocab.spm"),
|
| 120 |
+
dstVocabSrc: path.join(dir, "vocab.spm"),
|
| 121 |
+
},
|
| 122 |
+
});
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
async function translateText(modelId, text) {
|
| 126 |
+
const { text: out } = translate({ modelId, text, modelType: "nmt", stream: false });
|
| 127 |
+
return (await out).trim();
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
// English -> German: prepend the ##DE target tag (see Translation Directions).
|
| 131 |
+
const ende = await load("en-xx", "en", "de");
|
| 132 |
+
console.log(await translateText(ende, "##DE Good morning, how are you today?"));
|
| 133 |
+
await unloadModel({ modelId: ende });
|
| 134 |
+
|
| 135 |
+
// German -> English: no tag needed.
|
| 136 |
+
const deen = await load("xx-en", "de", "en");
|
| 137 |
+
console.log(await translateText(deen, "Guten Morgen, wie geht es Ihnen heute?"));
|
| 138 |
+
await unloadModel({ modelId: deen });
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
```bash
|
| 142 |
+
node quickstart.mjs
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
Output:
|
| 146 |
+
|
| 147 |
+
```text
|
| 148 |
+
Guten Morgen, wie geht es dir heute?
|
| 149 |
+
Good morning. How are you doing today?
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
**Notes**
|
| 153 |
+
|
| 154 |
+
- **English → European (`en-xx`):** prepend the target tag (`##DE`, `##FR`, `##ES`, …) to the source text, as listed under [Translation Directions](#english--european-en-xx).
|
| 155 |
+
- **European → English (`xx-en`):** no tag required.
|
| 156 |
+
- **European → European:** pivot through English — run `xx-en` first, then feed the English output (with the target tag) into `en-xx`.
|
| 157 |
+
- Load a pack once and reuse the returned `modelId` for many translations; call `unloadModel` to free the memory when you're done.
|
| 158 |
+
- For token-by-token streaming, pass `stream: true` and iterate `translate(...).tokenStream` instead.
|
| 159 |
+
|
| 160 |
+
|
| 161 |
# Model Details
|
| 162 |
|
| 163 |
## Architecture
|