Skip to main content

spaCy pipelines for pre-trained BERT and other transformers

Project description

spacy-transformers: Use pretrained transformers like BERT, XLNet and GPT-2 in spaCy

This package provides spaCy components and architectures to use transformer models via Hugging Face's transformers in spaCy. The result is convenient access to state-of-the-art transformer architectures, such as BERT, GPT-2, XLNet, etc.

This release requires spaCy v3. For the previous version of this library, see the v0.6.x branch.

tests PyPi GitHub Code style: black

Features

  • Use pretrained transformer models like BERT, RoBERTa and XLNet to power your spaCy pipeline.
  • Easy multi-task learning: backprop to one transformer model from several pipeline components.
  • Train using spaCy v3's powerful and extensible config system.
  • Automatic alignment of transformer output to spaCy's tokenization.
  • Easily customize what transformer data is saved in the Doc object.
  • Easily customize how long documents are processed.
  • Out-of-the-box serialization and model packaging.

🚀 Installation

Installing the package from pip will automatically install all dependencies, including PyTorch and spaCy. Make sure you install this package before you install the models. Also note that this package requires Python 3.6+, PyTorch v1.5+ and spaCy v3.0+.

pip install 'spacy[transformers]'

For GPU installation, find your CUDA version using nvcc --version and add the version in brackets, e.g. spacy[transformers,cuda92] for CUDA9.2 or spacy[transformers,cuda100] for CUDA10.0.

If you are having trouble installing PyTorch, follow the instructions on the official website for your specific operating system and requirements.

📖 Documentation

⚠️ Important note: This package has been extensively refactored to take advantage of spaCy v3.0. Previous versions that were built for spaCy v2.x worked considerably differently. Please see previous tagged versions of this README for documentation on prior versions.

Applying pretrained text and token classification models

Note that the transformer component from spacy-transformers does not support task-specific heads like token or text classification. A task-specific transformer model can be used as a source of features to train spaCy components like ner or textcat, but the transformer component does not provide access to task-specific heads for training or inference.

Alternatively, if you only want use to the predictions from an existing Hugging Face text or token classification model, you can use the wrappers from spacy-huggingface-pipelines to incorporate task-specific transformer models into your spaCy pipelines.

Bug reports and other issues

Please use spaCy's issue tracker to report a bug, or open a new thread on the discussion board for any other issue.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spacy-transformers-1.3.4.tar.gz (49.1 kB view hashes)

Uploaded Source

Built Distributions

spacy_transformers-1.3.4-cp311-cp311-win_amd64.whl (343.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

spacy_transformers-1.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (197.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

spacy_transformers-1.3.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (190.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

spacy_transformers-1.3.4-cp311-cp311-macosx_11_0_arm64.whl (174.3 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

spacy_transformers-1.3.4-cp311-cp311-macosx_10_9_x86_64.whl (180.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

spacy_transformers-1.3.4-cp310-cp310-win_amd64.whl (343.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

spacy_transformers-1.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (197.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

spacy_transformers-1.3.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (191.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

spacy_transformers-1.3.4-cp310-cp310-macosx_11_0_arm64.whl (174.2 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

spacy_transformers-1.3.4-cp310-cp310-macosx_10_9_x86_64.whl (180.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

spacy_transformers-1.3.4-cp39-cp39-win_amd64.whl (343.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

spacy_transformers-1.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (198.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

spacy_transformers-1.3.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (191.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

spacy_transformers-1.3.4-cp39-cp39-macosx_11_0_arm64.whl (174.4 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

spacy_transformers-1.3.4-cp39-cp39-macosx_10_9_x86_64.whl (180.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

spacy_transformers-1.3.4-cp38-cp38-win_amd64.whl (343.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

spacy_transformers-1.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

spacy_transformers-1.3.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (192.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

spacy_transformers-1.3.4-cp38-cp38-macosx_11_0_arm64.whl (173.7 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

spacy_transformers-1.3.4-cp38-cp38-macosx_10_9_x86_64.whl (180.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

spacy_transformers-1.3.4-cp37-cp37m-win_amd64.whl (341.5 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

spacy_transformers-1.3.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (194.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

spacy_transformers-1.3.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (188.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

spacy_transformers-1.3.4-cp37-cp37m-macosx_10_9_x86_64.whl (178.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page