Skip to main content

A translator wrapper for open-source translation models with batch optimization. Currently supports ArgosTranslate models and is designed for scalable deployment.

Project description

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.Series of 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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abtranslate-0.2.0rc0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abtranslate-0.2.0rc0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file abtranslate-0.2.0rc0.tar.gz.

File metadata

  • Download URL: abtranslate-0.2.0rc0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for abtranslate-0.2.0rc0.tar.gz
Algorithm Hash digest
SHA256 e89f06813525da45955adcaabec8e228dae9c4f2bae3a9f8a1af38d159414882
MD5 055eeeb7e8fa476831f2b504e7933d5f
BLAKE2b-256 20f897af423e483676bd35a4d905954952029399e9acc1e010e7171fc643140a

See more details on using hashes here.

File details

Details for the file abtranslate-0.2.0rc0-py3-none-any.whl.

File metadata

  • Download URL: abtranslate-0.2.0rc0-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for abtranslate-0.2.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 a040d1d3b98ae83cca1abe1516f6c5e5e31926b50c2d5e39d6a926a9ebca9be2
MD5 8393475653df4b5b9aee6d924ca3a94d
BLAKE2b-256 9158b9384a477d8ac1859dc261b1ce287e5acf06c6657a14ddf22bd19368b282

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page