Netra-NMT / web /README.md
Darayut's picture
Add web/ graphs for in-browser inference
57c36fb verified
|
Raw History Blame Contribute Delete
1.63 kB
# Netra NMT for the browser
A smaller copy of `model/` for in-browser inference with onnxruntime-web, used by the Netra MT playground on the Netra Lab website. The graphs have the same inputs and outputs as `model/`, so the decoding code is the same.
| File | Contents |
|---|---|
| `encoder.onnx` | the encoder, weight matrices stored as int8 |
| `decoder_step.onnx` | one decoding step with the KV cache, weight matrices stored as int8 |
| `embed.bin` | the shared embedding table in fp16, external data for both graphs |
| `netra-model.json`, `spm_32k.model` | settings and tokenizer, as in `model/` |
## What changed from `model/`
- **Weight matrices stored as int8**, one fp32 scale per output channel. A Cast and a Mul turn them back into fp32, and ONNX Runtime folds those when the session is created, so the arithmetic is fp32 as before.
- **The embedding stays fp16.** It is also the tied output head, and int8 there cost 0.7 spBLEU Khmer→English.
- **One embedding file.** Both graphs read the embedding table from `embed.bin`, so it downloads once. Pass it to both sessions as external data (`externalData: [{ path: "embed.bin", data }]`).
- **Size:** 95 MB in total, against 188 MB for `model/`.
## Quality
ALT test split (1,018 pairs), greedy decoding, same pipeline as the model card:
| Graphs | Size | EN → KM spBLEU | KM → EN spBLEU | EN → KM chrF++ | KM → EN chrF++ |
|---|---:|---:|---:|---:|---:|
| `model/` (fp16) | 188 MB | 25.84 | 19.43 | 38.06 | 46.00 |
| `web/` | 95 MB | 25.83 | 19.36 | 38.05 | 45.94 |
Built by `scripts/netra-nmt-web/export.py` in the Netra Lab website repository.