asian_mtl
This repository contains the code and documentation for the machine translation models used for EasierMTL's API.
Improved version of the models in the original repository: EasierMTL/chinese-translation-app
Supported Translators
All translators support dynamic quantization! Our benchmarks indicate that they 2x inference speeds, while losing <1% BLEU.
ChineseToEnglishTranslator()EnglishToChineseTranslator()
Getting Started
pip install asian-mtl
Here's a simple example:
from asian_mtl.models.base import ChineseToEnglishTranslator
translator = ChineseToEnglishTranslator()
# Quantize for better CPU production performance!
translator.quantize()
prediction = translator.predict("我爱ECSE484.")
print(prediction)
# prediction will be:
# "I love ECSE 484."
And you're good to go!
If you are contributing, run:
# https://stackoverflow.com/questions/59882884/vscode-doesnt-show-poetry-virtualenvs-in-select-interpreter-option
poetry config virtualenvs.in-project true
# shows the name of the current environment
poetry env list
poetry install
Usage
When you are using quantized models in this repository, make sure to set torch.set_num_threads(1). This is not set under-the-hood because it could interfere with user setups in an invasive way.
Not doing so will make the quantized models slower than their vanilla counterparts.
Evaluation
See scripts for evaluation scripts.
To run the scripts, simply run:
# Running with CLI and config with BERT
python ./scripts/evaluation/eval.py -c ./scripts/evaluation/configs/helsinki.yaml
Change the config helsinki.yaml to use quantized or your specific use case.
Benchmarks
Here are some basic benchmarks of models in this repository:
| Model | Quantized? | N | BLEU | Runtime |
|---|---|---|---|---|
| Helsinki-NLP/opus-mt-zh-en | No | 100 | 0.319 | 27s |
| Yes | 100 | 0.306 | 13.5s |
The benchmarks described in the docs are a little out-of-date.
Metadata
Release files for asian-mtl 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| asian_mtl-0.1.2.tar.gz | 8.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asian_mtl-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / asian_mtl-0.1.2.tar.gz
| Download URL | asian_mtl-0.1.2.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c9bb678d1e2eddf467311189a689cbd58b80edd450c1065fc3945715781f169
|
|
BLAKE2b-256 checksum How to use checksums |
6837ae97e331e7bd133b522e4f434d5f1c57d71f0457da3239d73054f1a0b5cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.5 Linux/5.15.0-53-generic
|
Release files / asian_mtl-0.1.2-py3-none-any.whl
| Download URL | asian_mtl-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2371e184cb00c0404afbe8dbce5874c3b1bfc0f4ffb056f0b8efdfd640db3e0a
|
|
BLAKE2b-256 checksum How to use checksums |
5c4b1b13c34c66a89bd7db77b1fa88b2bd462ae00019215d1bcd527575de7ee5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.5 Linux/5.15.0-53-generic
|
Security for asian-mtl 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.