Python bindings for Transformer models implemented in C/C++ using the GGML library. Provides a high-level API for inference with popular models (LLaMA, Falcon, GPT-J, StarCoder, etc.) in GGML/GGUF format, with optional GPU acceleration (CUDA, Metal, ROCm). Latest version 0.2.27, active development.
pip install ctransformersVerified import paths — ran on the pinned version, not inferred.
Load a GGML model from Hugging Face Hub and generate text. Replace model ID with a valid GGML/GGUF model.
Remove calls to LLM.reset() and use high-level API (AutoModelForCausalLM).
Use GGUF v2 models or convert your model to GGUF format using llama.cpp convert scripts.
Install with the correct extra, e.g., pip install ctransformers[cuda]. Note: CUDA support is experimental for some model types.
Pass model_type parameter, e.g., AutoModelForCausalLM.from_pretrained('./model.gguf', model_type='llama').Install with: pip install ctransformers. If you need GPU, use pip install ctransformers[cuda] (or [metal]/[rocm]).
Use: from ctransformers import AutoModelForCausalLM. Ensure you have ctransformers >=0.2.0.
Specify model_type explicitly, e.g., AutoModelForCausalLM.from_pretrained('path/to/model', model_type='llama').No dependency data recorded yet.