spacy-transformers
spaCy pipelines for pre-trained BERT and other transformers
What it is and what it does
spacy-transformers is a spaCy extension that wraps Hugging Face's transformer models to use them as feature extractors within spaCy pipelines. It handles the integration layer between transformer token outputs and spaCy's tokenization, allowing you to build NLP systems that combine transformer embeddings with spaCy's task-specific components (named entity recognition, text classification, dependency parsing, etc.). The package supports multi-task learning, where a single transformer backbone can backpropagate gradients from multiple downstream components simultaneously.
The package is designed for developers building production NLP systems who want to leverage state-of-the-art pretrained models without abandoning spaCy's configuration, training, and serialization workflows. It requires PyTorch and spaCy v3.0+, and comes with prebuilt wheels for modern Python versions and common platforms. The main constraint is the size and memory footprint of transformer models themselves—BERT-scale models require significant RAM and benefit from GPU acceleration.
Use it for:
- Train named entity recognition or text classification on top of BERT embeddings using spaCy's standard training pipeline
- Build multi-task NLP systems where one transformer model feeds features to multiple downstream components
- Align transformer token outputs to spaCy's linguistic tokenization for languages with complex morphology
- Serialize and package transformer-based spaCy models for production deployment with built-in model versioning
- Customize which transformer layers and outputs are stored in the Doc object to balance memory and performance
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Integrates pretrained transformer models (BERT, RoBERTa, XLNet, GPT-2) into spaCy pipelines via Hugging Face's transformers library, enabling state-of-the-art neural NLP components with automatic tokenization alignment.
Yes, if you need transformer models in spaCy. The package is actively maintained, has no known vulnerabilities, and integrates cleanly into spaCy's v3+ ecosystem. Install friction is moderate due to PyTorch and transformers dependencies, but prebuilt wheels cover standard platforms. Not necessary if you only need transformer predictions without spaCy's downstream components—use Hugging Face transformers directly in that case.
Install
spacy-transformers on PyPI
pip
pip install spacy-transformersuv
uv add spacy-transformerspoetry
poetry add spacy-transformersInstalling spacy-transformers
Before you install
Medium install friction due to 7 runtime dependencies including PyTorch, transformers, and spaCy. Prebuilt wheels available for Python 3.10–3.13 across macOS, Linux, and Windows. Last release 150 days ago with active maintenance status.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in commercial or private projects.
Quickstart
pip install 'spacy[transformers]'
import spacy
from spacy_transformers import Transformer
nlp = spacy.load('en_core_web_trf')
doc = nlp('Hello world')
Requires PyTorch v1.5+, spaCy v3.0+, and Python 3.10+. GPU support requires CUDA toolkit; CPU-only installation is possible but slower for inference.
Verify before relying
- Whether pretrained transformer models are bundled or must be downloaded separately from Hugging Face
- Memory and compute requirements for inference with large transformer models
- Performance characteristics compared to direct Hugging Face transformer use
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 7 — spacy, numpy, transformers, torch, srsly, dataclasses, spacy-alignments |
| Maintenance | actively maintained — 150 days since the last release |
| First released | |
| Downloads | 271,076/month — #8,224 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: spacy_transformers-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl; spacy_transformers-1.4.0-cp310-cp310-macosx_11_0_arm64.whl; spacy_transformers-1.4.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; spacy_transformers-1.4.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; spacy_transformers-1.4.0-cp310-cp310-musllinux_1_2_aarch64.whl; spacy_transformers-1.4.0-cp310-cp310-musllinux_1_2_x86_64.whl; spacy_transformers-1.4.0-cp310-cp310-win_amd64.whl; spacy_transformers-1.4.0-cp311-cp311-macosx_10_9_x86_64.whl; spacy_transformers-1.4.0-cp311-cp311-macosx_11_0_arm64.whl; spacy_transformers-1.4.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; spacy_transformers-1.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; spacy_transformers-1.4.0-cp311-cp311-musllinux_1_2_aarch64.whl; spacy_transformers-1.4.0-cp311-cp311-musllinux_1_2_x86_64.whl; spacy_transformers-1.4.0-cp311-cp311-win_amd64.whl; spacy_transformers-1.4.0-cp311-cp311-win_arm64.whl; spacy_transformers-1.4.0-cp312-cp312-macosx_10_13_x86_64.whl; spacy_transformers-1.4.0-cp312-cp312-macosx_11_0_arm64.whl; spacy_transformers-1.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; spacy_transformers-1.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; spacy_transformers-1.4.0-cp312-cp312-musllinux_1_2_aarch64.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
pytorch-pretrained-bertProvides PyTorch implementations of BERT, GPT,…
permissive · top 15,000 on PyPI
sentence-transformersComputes embeddings and reranking scores for…
permissive · top 1,000 on PyPI
spacy-alignmentsAligns tokenizations between spaCy and…
permissive · top 15,000 on PyPI
spacy-curated-transformersIntegrates curated transformer models (ALBERT,…
permissive · top 5,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
spacyspaCy is an industrial-strength NLP library…
permissive · top 1,000 on PyPI
xformersXFormers provides reusable, composable building…
permissive · top 5,000 on PyPI
curated-transformersCurated Transformers provides PyTorch…
permissive · top 5,000 on PyPI
spacy-loggersProvides logging integrations for spaCy model…
permissive · top 5,000 on PyPI
transformers-stream-generatorModifies Hugging Face Transformers…
permissive · top 15,000 on PyPI