Metadata-Version: 2.4
Name: linguonnx
Version: 0.26.9a1
Summary: CPU-first language technology models on ONNX Runtime: language identification and machine translation, with no torch at runtime
Author-email: jarbasAi <jarbasai@mailfence.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/TigreGotico/linguonnx
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: onnxruntime>=1.22.0
Requires-Dist: numpy>=1.21.0
Requires-Dist: huggingface_hub>=0.20.0
Requires-Dist: linguatag>=0.10.0a1
Requires-Dist: sentencepiece>=0.2.0
Provides-Extra: distance
Requires-Dist: orthography2ipa>=0.1.0; extra == "distance"
Provides-Extra: indic
Requires-Dist: regex>=2021.8.3; extra == "indic"
Requires-Dist: sacremoses>=0.0.53; extra == "indic"
Requires-Dist: indic-nlp-library-itt>=0.1.1; extra == "indic"
Provides-Extra: opennmt
Requires-Dist: sacremoses>=0.0.53; extra == "opennmt"
Requires-Dist: subword-nmt>=0.3.8; extra == "opennmt"
Provides-Extra: fast-tokenizers
Requires-Dist: tokenizers>=0.15.0; extra == "fast-tokenizers"
Requires-Dist: regex>=2021.8.3; extra == "fast-tokenizers"
Provides-Extra: rules
Requires-Dist: pt2barranquenho>=0.1.0a2; extra == "rules"
Requires-Dist: pt2mirandese>=0.0.1a2; extra == "rules"
Provides-Extra: cpu
Provides-Extra: gpu
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: langcodes>=3.3.0; extra == "test"
Requires-Dist: onnx!=1.23.0rc1,>=1.16.0; extra == "test"
Requires-Dist: linguonnx[distance,fast-tokenizers,indic,opennmt,rules]; extra == "test"
Requires-Dist: transformers==4.57.6; extra == "test"
Requires-Dist: IndicTransToolkit>=1.1.1; extra == "test"
Dynamic: license-file

# linguonnx
<!-- agent-hint: language identification and machine translation on ONNX Runtime, no torch. Verify the examples: `python scripts/check_docs.py README.md` (downloads models). -->

Language identification and machine translation on CPU, with ONNX Runtime and
no torch.

- `linguonnx.detect` identifies the language of a text with ONNX exports of
  four fastText classifiers: GlotLID, lid.176, OpenLID and OpenLID-v2.
- `linguonnx.translate` translates with Marian (opus-mt), M2M100, NLLB-200 and
  MADLAD exports. A routing graph selects the model, or the chain of models,
  for a language pair.

## Install

```bash
pip install linguonnx
```

## Quickstart

```python
from linguonnx import load_detector, load_translator

det = load_detector()            # glotlid-int8, 425 MB on first use
print(det.detect("Egun on, zer moduz?"))              # 'eu'
print(det.detect("وش لونك يا خوي", collapse_varieties=True))   # 'ar'

tx = load_translator()
print(tx.translate("bom dia, como estás?", src="pt", tgt="en"))
# 'Good morning, how are you?'

route = tx.route("pt", "eu", prefer="dedicated")
print(route.model_ids)      # ('aina-translator-pt-ca-int8', 'mt-hitz-ca-eu-int8')
print(route.pivots)         # ('ca',)
```

A pair that no single model covers goes through a third language. The `Route`
shows each model and each pivot language.

## Documentation

| Page | Contents |
| --- | --- |
| [docs/index.md](docs/index.md) | What ships, and the reading order |
| [docs/install.md](docs/install.md) | Extras, GPU, the model cache, OpenVoiceOS, development |
| [docs/detect.md](docs/detect.md) | Language identification |
| [docs/translate.md](docs/translate.md) | The translation API |
| [docs/routing.md](docs/routing.md) | How the router selects a route |
| [docs/models.md](docs/models.md) | The model registry |
| [docs/licences.md](docs/licences.md) | Licence tiers and non-commercial models |

## Licence

`linguonnx` is Apache-2.0. Some models have other licences: OpenLID is
GPL-3.0, and NLLB-200 is CC-BY-NC-4.0. The default translation graph has no
non-commercial model. See [docs/licences.md](docs/licences.md).
