Three backends, one library
The transformers library targets PyTorch (default), TensorFlow, and JAX/Flax. In 2026 the only backend you should reach for is PyTorch unless you have a specific reason — TF support is in maintenance mode upstream, JAX/Flax is alive but a niche choice for research. On Apple Silicon, PyTorch with MPS is the default; for serious local inference the MLX backend (separate from transformers) wins on memory.
What you install:
transformers— the model classes, tokenizers, pipelines.torch— the backend. Pick the wheel matching your hardware (CUDA, MPS, CPU).accelerate— required for any multi-GPU / mixed-precision / device_map auto.safetensors— safe weight format. Bundled with modern transformers.- Optional:
bitsandbytesfor 8/4-bit quantization,peftfor LoRA,datasetsfor data loading.
Verify the install with transformers-cli env
Before you debug "why is this slow," run transformers-cli env. The output is the answer to 80% of "is my CUDA actually working" tickets — it prints the platform, Python, transformers, and torch versions; whether CUDA / MPS is available; and the GPU name. Paste this into any bug report.