Why PyTorch Only?

Transformers 5.0 drops TensorFlow and Flax backends to focus exclusively on PyTorch. This decision reflects PyTorch's massive adoption in research and industry, and significantly reduces the project's maintenance surface.

What Changes

The TF* and Flax* classes are removed. Only the unprefixed (PyTorch) classes remain. Pre-trained weights are still available and convertible via provided migration scripts.

python
# Before (Transformers 4.x): three variants
# from transformers import BertModel          # PyTorch
# from transformers import TFBertModel        # TensorFlow
# from transformers import FlaxBertModel      # Flax/JAX

# After (Transformers 5.0): only one
from transformers import BertModel

model = BertModel.from_pretrained('bert-base-uncased')
print(type(model))  # BertModel (PyTorch)

# Migration from TF: convert weights
# python -m transformers.convert_tf_to_pytorch \
#     --model_name bert-base-uncased \
#     --tf_checkpoint tf_model.h5 \
#     --output pytorch_model.bin

Sources