ctranslate2
Fast inference engine for Transformer models
What it is and what it does
CTranslate2 is a specialized inference runtime for Transformer models that prioritizes speed and memory efficiency over generality. It implements a custom C++ engine with performance optimizations including weights quantization (INT8, INT16, FP16, BF16, AWQ), layer fusion, batch reordering, and caching, targeting both CPU and GPU deployment. The library supports a wide range of model architectures—from translation models like BART and T5 to large language models like Llama and Mistral—and includes converters for popular training frameworks (Transformers, PyTorch, TensorFlow, Fairseq, Marian).
You use CTranslate2 when you need to serve Transformer models in production with lower latency and memory footprint than general-purpose deep learning frameworks. After converting a trained model to CTranslate2 format, you instantiate a Translator or Generator object and call batch methods to process sequences. The library handles automatic CPU backend selection, parallel execution across multiple GPUs or cores, and dynamic memory allocation. It trades model flexibility and training capability for substantial inference speedups—benchmarks show 2–3× throughput gains on CPU and comparable or better performance on GPU compared to PyTorch and TensorFlow, with quantization reducing model size by up to 4×.
Use it for:
- Deploy machine translation models in production with lower latency and memory than PyTorch or TensorFlow.
- Serve large language models on resource-constrained hardware using INT8 or INT16 quantization.
- Run inference on edge devices or embedded systems where model size and memory footprint are critical.
- Batch-process text generation or translation tasks with automatic parallelization across CPU cores or multiple GPUs.
- Integrate Transformer inference into web services or microservices with minimal dependencies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
CTranslate2 is a C++ and Python library that runs Transformer models for inference with optimizations like quantization and layer fusion, supporting encoder-decoder, decoder-only, and encoder-only architectures on CPU and GPU.
Yes. CTranslate2 is production-ready (Development Status 5), actively maintained, has no known vulnerabilities, and solves a real problem: efficient Transformer inference. Install it if you need to serve Transformer models with lower latency and memory than standard frameworks. The medium install friction is offset by pre-built wheels for common platforms and Python versions. The main gotcha is that models must be converted to CTranslate2 format first, which requires familiarity with the conversion tools.
Install
ctranslate2 on PyPI
pip
pip install ctranslate2uv
uv add ctranslate2poetry
poetry add ctranslate2Installing ctranslate2
Before you install
Medium install friction: pre-built wheels cover Python 3.10–3.13 across macOS (ARM64 and x86_64), Linux (x86_64 and AArch64), and Windows. Active maintenance with last commit 2026-08-05 and a recent release 42 days ago.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install ctranslate2
import ctranslate2
translator = ctranslate2.Translator(model_path)
result = translator.translate_batch(tokens)
Requires Python >=3.9; GPU support depends on CUDA 12.4 or compatible hardware; models must be converted to CTranslate2 format first using provided converters.
Verify before relying
- Whether pre-built wheels include all optional backends (Intel MKL, oneDNN, OpenBLAS, Ruy, Apple Accelerate) or if some require separate installation.
- Whether AMD ROCm GPU wheels mentioned in the description are available on PyPI or only on GitHub releases.
- Performance characteristics on specific hardware configurations beyond the benchmarks shown (e.g., consumer GPUs, older CPUs).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 3 — setuptools, numpy, pyyaml |
| Maintenance | actively maintained — 42 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,724,102/month — #1,440 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ctranslate2-4.8.1-cp310-cp310-macosx_11_0_arm64.whl; ctranslate2-4.8.1-cp310-cp310-macosx_11_0_x86_64.whl; ctranslate2-4.8.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; ctranslate2-4.8.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; ctranslate2-4.8.1-cp310-cp310-win_amd64.whl; ctranslate2-4.8.1-cp311-cp311-macosx_11_0_arm64.whl; ctranslate2-4.8.1-cp311-cp311-macosx_11_0_x86_64.whl; ctranslate2-4.8.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; ctranslate2-4.8.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; ctranslate2-4.8.1-cp311-cp311-win_amd64.whl; ctranslate2-4.8.1-cp312-cp312-macosx_11_0_arm64.whl; ctranslate2-4.8.1-cp312-cp312-macosx_11_0_x86_64.whl; ctranslate2-4.8.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; ctranslate2-4.8.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; ctranslate2-4.8.1-cp312-cp312-win_amd64.whl; ctranslate2-4.8.1-cp313-cp313-macosx_11_0_arm64.whl; ctranslate2-4.8.1-cp313-cp313-macosx_11_0_x86_64.whl; ctranslate2-4.8.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; ctranslate2-4.8.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; ctranslate2-4.8.1-cp313-cp313-win_amd64.whl
Keywords: opennmt, nmt, neural, machine, translation, cuda, mkl, inference, quantization
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
faster-whisperTranscribes audio to text using OpenAI's…
permissive · top 5,000 on PyPI
argostranslateArgos Translate is an open-source offline…
permissive · top 15,000 on PyPI
transformer-engineTransformer Engine accelerates Transformer…
unclear · top 15,000 on PyPI
transformer-engine-cu13Accelerates Transformer model training and…
unclear · top 15,000 on PyPI
transformer-engine-cu12Accelerates Transformer model training and…
unclear · top 15,000 on PyPI
optimum-quantoA PyTorch quantization backend that reduces…
permissive · top 15,000 on PyPI
auto-gptqQuantizes large language models to lower…
permissive · top 15,000 on PyPI
megatron-coreMegatron Core provides GPU-optimized building…
permissive · top 15,000 on PyPI
spacy-transformersIntegrates pretrained transformer models (BERT,…
permissive · top 15,000 on PyPI
tensorrt-cu13-libsProvides NVIDIA TensorRT libraries for…
unclear · top 15,000 on PyPI