skillfed

spacy-transformers

spaCy pipelines for pre-trained BERT and other transformers

spacy-transformers v1.4.0 271.1K downloads/30d#8,224 on PyPI
Permissive license MIT Active released

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-transformers

uv

uv add spacy-transformers

poetry

poetry add spacy-transformers

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial Intelligence

Tags

transformer models in spacybert spacy pipelinehugging face transformers spacypretrained nlp models spacyspacy neural componentstransformer embeddings spacymulti-task learning nlp
transformer-modelsspacy-extensionnlp-pipeline

More Scientific/Engineering packages