-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
32 lines (29 loc) · 1.09 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as nllb from "./dist/nllb-200.mjs";
(async function () {
const text =
"Lockheed Martin Delivers Initial 5G Testbed To U.S. Marine Corps And Begins Mobile Network Experimentation";
const source = "eng";
const targets = ["zho", "kor", "jpn"];
const model = nllb.MODELS[0];
// 0: 'facebook/nllb-200-distilled-600M' <= default
// 1: 'facebook/nllb-200-distilled-1.3B'
// 2: 'facebook/nllb-200-1.3B'
// 3: 'facebook/nllb-200-3.3B'
// 4: 'facebook/nllb-moe-54b'
// Create virtual environment
// At first, initialize take a long time for download requirements.
// The device must be installed Python3
// https://www.python.org/downloads/
await nllb.init();
for (const target of targets) {
try {
// At first translate, initialize take a long time for download nllb model.
// it requires at least 8 GB of available storage during initialization.
const result = await nllb.translate(text, source, target, model);
console.log(`${target}: ${result}`);
} catch (err) {
console.error(`${target} ERROR`);
console.error(err);
}
}
})();