Fast inference engine for Transformer models
Actively maintained. Last release 8 days ago, commits in 15 of the last 26 weeks. A safe choice.
pip install ctranslate2CTranslate2
CTranslate2 is a C++ and Python library for efficient inference with Transformer models.
The project implements a custom runtime that applies many performance optimization techniques such as weights quantization, layers fusion, batch reordering, etc., to accelerate and reduce the memory usage of Transformer models on CPU and GPU.
The following model types are currently supported:
- Encoder-decoder models: Transformer base/big, M2M-100, NLLB, BART, mBART, Pegasus, T5, UMT5, Whisper, T5Gemma, T5Gemma2, MADLAD-400
- Decoder-only models: GPT-2, GPT-J, GPT-NeoX, OPT, BLOOM, MPT, Llama, Mistral, Gemma, CodeGen, GPTBigCode, Falcon, Qwen2
- Encoder-only models: BERT, DistilBERT, XLM-RoBERTa
- Text-to-speech (TTS) models: Drama 3 (experimental)
Compatible models should be first converted into an optimized model format. The library includes converters for multiple frameworks:
The project is production-oriented and comes with , but it also includes experimental features related to model compression and inference acceleration.