ABTranslate
A translator wrapper for open-source translation models with batch optimization. Currently supports ArgosTranslate models and is designed for scalable deployment.
Features
- ✅ Optimized translation for list or
pandas.Seriesof text - 🛡️ Supports masking of specific patterns to exclude them from translation
- ⚙️ Thread-tuned for multi-threaded deployment with
ctranslate2 - 📦 Compatible with ArgosTranslate model packages
Installation
pip install abtranslate
Usage
from abtranslate import load_argostranslate_model
# Load model from local path
model_package = load_argostranslate_model(model_path, package_dir=package_extraction_dir)
# Load translator with optional optimizations
translator = model_package.load_translator(optimized_config=True, lazy_load=False)
# Define translation quality settings (based on CTranslate2)
QUALITY_CONFIG = {
"beam_size": 4,
"num_hypotheses": 1,
"replace_unknowns": True,
}
# Translate a batch of texts (e.g. pandas Series or list)
translated_texts = translator.translate_batch(df["input_text"], translation_config=QUALITY_CONFIG)
🔗 Refer to CTranslate2 Translate Batch Parameters for more configuration options.
Main Functions
-
load_argostranslate_model(model_path: str, package_dir: str) -> ModelPackage: Loads and prepares an ArgosTranslate model for usage. -
ModelPackage.load_translator(translator_config: dict, optimized_config: bool, lazy_load: bool) -> Translator: Returns a translator instance with optional optimizations. -
Translator.translate_batch(text_list: List[str] | pd.Series, translation_config: dict, return_type: any) -> List[str]: Performs high-performance batch translation with support for multi-threading and tuning.
License
MIT
Author
Ichsan Takwa GitHub
Metadata
Release files for abtranslate 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| abtranslate-0.2.0.tar.gz | 24.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| abtranslate-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.7 kB
Release files / abtranslate-0.2.0.tar.gz
| Download URL | abtranslate-0.2.0.tar.gz |
|---|---|
| Size | 24.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68645740bc40fd7646bb3876b72eb001844bfec13ed3817780a1661e460e7207
|
|
BLAKE2b-256 checksum How to use checksums |
31a14d8f7db03d3c6ceb91b22599cd0d679e97a36cf0b38718e18c00eb443edd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|
Release files / abtranslate-0.2.0-py3-none-any.whl
| Download URL | abtranslate-0.2.0-py3-none-any.whl |
|---|---|
| Size | 27.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d47c848355c4260da5dc806ae2a05a0c9552b5abed58e7841da5639ca45b602c
|
|
BLAKE2b-256 checksum How to use checksums |
3de8c20d5cd580ea2bbf3b62c4eab6ac32f5671fed5ca141230b56718b64e674
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|