Skip to main content

Curated Transformers

Documentation Status pypi Version

State-of-the-art transformers, brick by brick

Curated Transformers is a transformer library for PyTorch. It provides state-of-the-art models that are composed from a set of reusable components. The stand-out features of Curated Transformer are:

  • ⚡️ Supports state-of-the art transformer models, including LLMs such as Falcon, Llama, and Dolly v2.
  • 👩‍🎨 Each model is composed from a set of reusable building blocks, providing many benefits:
    • Implementing a feature or bugfix benefits all models. For example, all models support 4/8-bit inference through the bitsandbytes library and each model can use the PyTorch meta device to avoid unnecessary allocations and initialization.
    • Adding new models to the library is low-effort.
    • Do you want to try a new transformer architecture? A BERT encoder with rotary embeddings? You can make it in a pinch.
  • 💎 Consistent type annotations of all public APIs:
    • Get great coding support from your IDE.
    • Integrates well with your existing type-checked code.
  • 🎓 Great for education, because the building blocks are easy to study.
  • 📦 Minimal dependencies.

Curated Transformers has been production-tested by Explosion and will be used as the default transformer implementation in spaCy 3.7.

🧰 Supported Model Architectures

Supported encoder-only models:

  • ALBERT
  • BERT
  • CamemBERT
  • RoBERTa
  • XLM-RoBERTa

Supported decoder-only models:

  • Falcon
  • GPT-NeoX
  • Llama 1/2
  • MPT

Generator wrappers:

  • Dolly v2
  • Falcon
  • Llama 1/2
  • MPT

All types of models can be loaded from Huggingface Hub.

spaCy integration for curated transformers is provided by the spacy-curated-transformers package.

⏳ Install

pip install curated-transformers

CUDA support

The default Linux build of PyTorch is built with CUDA 11.7 support. You should explicitly install a CUDA build in the following cases:

  • If you want to use Curated Transformers on Windows.
  • If you want to use Curated Transformers on Linux with Ada-generation GPUs. The standard PyTorch build supports Ada GPUs, but you can get considerable performance improvements by installing PyTorch with CUDA 11.8 support.

In both cases, you can install PyTorch with:

pip install torch --index-url https://download.pytorch.org/whl/cu118

🏃‍♀️ Usage Example

>>> import torch
>>> from curated_transformers.generation import AutoGenerator, GreedyGeneratorConfig
>>> generator = AutoGenerator.from_hf_hub(name="tiiuae/falcon-7b-instruct", device=torch.device("cuda"))
>>> generator(["What is Python in one sentence?", "What is Rust in one sentence?"], GreedyGeneratorConfig())
['Python is a high-level programming language that is easy to learn and widely used for web development, data analysis, and automation.',
 'Rust is a programming language that is designed to be a safe, concurrent, and efficient replacement for C++.']

You can find more usage examples in the documentation. You can also find example programs that use Curated Transformers in the examples directory.

📚 Documentation

You can read more about how to use Curated Transformers here:

🗜️ Quantization

curated-transformers supports dynamic 8-bit and 4-bit quantization of models by leveraging the bitsandbytes library.

Use the quantization variant to automatically install the necessary dependencies:

pip install curated-transformers[quantization]

Release files for curated-transformers 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for curated-transformers 2.0.1
File Size Uploaded
curated_transformers-2.0.1.tar.gz 289.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for curated-transformers 2.0.1
File Interpreter ABI Platform
curated_transformers-2.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 652.5 kB

Release files / curated_transformers-2.0.1.tar.gz

Download URL curated_transformers-2.0.1.tar.gz
Size 289.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3348e639d9247bf222bcd90cefded05b37c5dc0e798b0af6957e37a4aafd0f1d
BLAKE2b-256 checksum
How to use checksums
f589ef25c717786a83d63bb47eb7092e8cf68732b1429ac01be91defebe94646
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release files / curated_transformers-2.0.1-py2.py3-none-any.whl

Download URL curated_transformers-2.0.1-py2.py3-none-any.whl
Size 363.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5da92a4bf41a8a0bebca39b65ede4db49a7bc78467ca3c3ba7f84ecdcc8c45e5
BLAKE2b-256 checksum
How to use checksums
1d1662dcf539c53ec0a7f27c308e4665aecd4e4eafa0c3b7d4fe544ab9409525
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page