Skip to main content

Thinc: A refreshing functional take on deep learning, compatible with your favorite libraries

From the makers of spaCy, Prodigy and FastAPI

Thinc is a lightweight deep learning library that offers an elegant, type-checked, functional-programming API for composing models, with support for layers defined in other frameworks such as PyTorch, TensorFlow and MXNet. You can use Thinc as an interface layer, a standalone toolkit or a flexible way to develop new models. Previous versions of Thinc have been running quietly in production in thousands of companies, via both spaCy and Prodigy. We wrote the new version to let users compose, configure and deploy custom models built with their favorite framework.

Azure Pipelines Current Release Version PyPi Version conda Version Python wheels Code style: black Open demo in Colab

🔥 Features

  • Type-check your model definitions with custom types and mypy plugin.
  • Wrap PyTorch, TensorFlow and MXNet models for use in your network.
  • Concise functional-programming approach to model definition, using composition rather than inheritance.
  • Optional custom infix notation via operator overloading.
  • Integrated config system to describe trees of objects and hyperparameters.
  • Choice of extensible backends.
  • Read more →

🚀 Quickstart

Thinc is compatible with Python 3.6+ and runs on Linux, macOS and Windows. The latest releases with binary wheels are available from pip. Before you install Thinc and its dependencies, make sure that your pip, setuptools and wheel are up to date. For the most recent releases, pip 19.3 or newer is recommended.

pip install -U pip setuptools wheel
pip install thinc --pre

See the extended installation docs for details on optional dependencies for different backends and GPU. You might also want to set up static type checking to take advantage of Thinc's type system.

⚠️ If you have installed PyTorch and you are using Python 3.7+, uninstall the package dataclasses with pip uninstall dataclasses, since it may have been installed by PyTorch and is incompatible with Python 3.7+.

📓 Selected examples and notebooks

Also see the /examples directory and usage documentation for more examples. Most examples are Jupyter notebooks – to launch them on Google Colab (with GPU support!) click on the button next to the notebook name.

Notebook Description
intro_to_thinc
Open in Colab
Everything you need to know to get started. Composing and training a model on the MNIST data, using config files, registering custom functions and wrapping PyTorch, TensorFlow and MXNet models.
transformers_tagger_bert
Open in Colab
How to use Thinc, transformers and PyTorch to train a part-of-speech tagger. From model definition and config to the training loop.
pos_tagger_basic_cnn
Open in Colab
Implementing and training a basic CNN for part-of-speech tagging model without external dependencies and using different levels of Thinc's config system.
parallel_training_ray
Open in Colab
How to set up synchronous and asynchronous parameter server training with Thinc and Ray.

View more →

📖 Documentation & usage guides

Introduction Everything you need to know.
Concept & Design Thinc's conceptual model and how it works.
Defining and using models How to compose models and update state.
Configuration system Thinc's config system and function registry.
Integrating PyTorch, TensorFlow & MXNet Interoperability with machine learning frameworks
Layers API Weights layers, transforms, combinators and wrappers.
Type Checking Type-check your model definitions and more.

🗺 What's where

Module Description
thinc.api User-facing API. All classes and functions should be imported from here.
thinc.types Custom types and dataclasses.
thinc.model The Model class. All Thinc models are an instance (not a subclass) of Model.
thinc.layers The layers. Each layer is implemented in its own module.
thinc.shims Interface for external models implemented in PyTorch, TensorFlow etc.
thinc.loss Functions to calculate losses.
thinc.optimizers Functions to create optimizers. Currently supports "vanilla" SGD, Adam and RAdam.
thinc.schedules Generators for different rates, schedules, decays or series.
thinc.backends Backends for numpy and cupy.
thinc.config Config parsing and validation and function registry system.
thinc.util Utilities and helper functions.

🐍 Development notes

Thinc uses black for auto-formatting, flake8 for linting and mypy for type checking. All code is written compatible with Python 3.6+, with type hints wherever possible. See the type reference for more details on Thinc's custom types.

👷‍♀️ Building Thinc from source

Building Thinc from source requires the full dependencies listed in requirements.txt to be installed. You'll also need a compiler to build the C extensions.

git clone https://github.com/explosion/thinc
cd thinc
python -m venv .env
source .env/bin/activate
pip install -U pip setuptools wheel
pip install -r requirements.txt
pip install --no-build-isolation .

Alternatively, install in editable mode:

pip install -r requirements.txt
pip install --no-build-isolation --editable .

Or by setting PYTHONPATH:

export PYTHONPATH=`pwd`
pip install -r requirements.txt
python setup.py build_ext --inplace

🚦 Running tests

Thinc comes with an extensive test suite. The following should all pass and not report any warnings or errors:

python -m pytest thinc    # test suite
python -m mypy thinc      # type checks
python -m flake8 thinc    # linting

To view test coverage, you can run python -m pytest thinc --cov=thinc. We aim for a 100% test coverage. This doesn't mean that we meticulously write tests for every single line – we ignore blocks that are not relevant or difficult to test and make sure that the tests execute all code paths.

Metadata

Release files for thinc 8.0.10

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

Source distribution (sdist)

Source distribution for thinc 8.0.10
File Size Uploaded
thinc-8.0.10.tar.gz 172.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for thinc 8.0.10
File
thinc-8.0.10-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
thinc-8.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
thinc-8.0.10-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
thinc-8.0.10-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
thinc-8.0.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
thinc-8.0.10-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
thinc-8.0.10-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
thinc-8.0.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
thinc-8.0.10-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
thinc-8.0.10-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
thinc-8.0.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details
thinc-8.0.10-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details

Total release size: 9.2 MB

Release files / thinc-8.0.10.tar.gz

Download URL thinc-8.0.10.tar.gz
Size 172.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b5e4db8d24e6be8a5f1e4a17854772b79a2b560224519f50a21f3951ca24001f
BLAKE2b-256 checksum
How to use checksums
446fde85e350344a6255fd9acccdabfc60a622fe6f4ea5f628d7a39932f99e37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp39-cp39-win_amd64.whl

Download URL thinc-8.0.10-cp39-cp39-win_amd64.whl
Size 1.0 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
1019c7e4715d95ebf482d0fed0557b2cae266faed84185d5fd955e9269847f35
BLAKE2b-256 checksum
How to use checksums
7328c1708f033b306d93951bc6ee3dd3806f59df90bad1d20ab585527f2a28c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL thinc-8.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 631.5 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1ec20c02c731846c76197270e6780fd06050dbce317d7b5532a4cd659ce5abd0
BLAKE2b-256 checksum
How to use checksums
32b3025757c331f3487fe667fad5c7c810d37b609052da47f125bf4da26bcdcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp39-cp39-macosx_10_9_x86_64.whl

Download URL thinc-8.0.10-cp39-cp39-macosx_10_9_x86_64.whl
Size 612.9 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
99fedb3350366a70fa09de6fd2fab1c0affc58892febd9c42dac57e8364f3b8c
BLAKE2b-256 checksum
How to use checksums
ebb72cf31ba1d1bc1b14d868741c8b8068bfe56a1d57de7ae1fee5dccffe06c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp38-cp38-win_amd64.whl

Download URL thinc-8.0.10-cp38-cp38-win_amd64.whl
Size 1.0 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
1b3c523f85bf7d546446e8f0c71f3da35d2595cbef300fccca80004f64cd0b49
BLAKE2b-256 checksum
How to use checksums
dd92618ae8ce4ba02739905aededd00a7856844ecdd409c88ed325f2f1716a4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL thinc-8.0.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 632.1 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5ef232642683268bc90d609dba9be9cc1e811fdea5a93b371d04afd8523c0418
BLAKE2b-256 checksum
How to use checksums
80554287c44e99a2676aa7885856f405052aa2e4c22a172f69ef224573c190a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp38-cp38-macosx_10_9_x86_64.whl

Download URL thinc-8.0.10-cp38-cp38-macosx_10_9_x86_64.whl
Size 607.0 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
c3553601642a4e27c4ec9d205941948bf913d34779f0b075d48790a02df4c7fb
BLAKE2b-256 checksum
How to use checksums
27b2b6c6d976d72df402aadde18f7db9af95c1e04362e394702fd3c1599d74a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp37-cp37m-win_amd64.whl

Download URL thinc-8.0.10-cp37-cp37m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
6740d750f69cbfc11c4c5e76d2c77616e3cae6a7b2778f6a680767c816407648
BLAKE2b-256 checksum
How to use checksums
58e116995127aa37ed9057afb578176a80d69afba77b6a95e3749d1831135fd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL thinc-8.0.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 623.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
128f4f98d85b3657036387cf2886c3b871a4fb5a099198d7c8911b19167302a6
BLAKE2b-256 checksum
How to use checksums
18cfe5286220208833574259d72f8fbccfe76f2b2ae516c829ccb5018c621b87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL thinc-8.0.10-cp37-cp37m-macosx_10_9_x86_64.whl
Size 599.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
df40bf1e07bcc72278939c9af831257bb7932b74b824cef27e38b6634a103699
BLAKE2b-256 checksum
How to use checksums
f91cad3ddee6011e7fc2adb39c0cf9dd8344bfd654cd5d891a54b9e7d5b9a121
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp36-cp36m-win_amd64.whl

Download URL thinc-8.0.10-cp36-cp36m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
933ebbb417d3f0fe35376500f8f068ba4bcc9528b63bd71bfa0ed0a9e137a9c2
BLAKE2b-256 checksum
How to use checksums
dfcfaa8af30c0023077f4cb61e156f4a6776083ccb9604ef62cb1efd78b9ff63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL thinc-8.0.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 625.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5f2fcbc805b27b55d31ad865450ec97433a667c2ddcc3c8a56a664425e52df37
BLAKE2b-256 checksum
How to use checksums
b39e96169ee3d7ee48e12aa9046c9d376ad861114ec20ed6e67b8ca68bd388f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release files / thinc-8.0.10-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL thinc-8.0.10-cp36-cp36m-macosx_10_9_x86_64.whl
Size 600.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
908912f2d36cf7826d7b2c466e7faa5922972c2a4f0c3a5a7d8f3dd791c80921
BLAKE2b-256 checksum
How to use checksums
fbb3823dabe95c13ee7c37015a3830403c34773625073b96d41ee9e309287e65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

Release history Release notifications | RSS feed

9.1.1

29 release files

9.0.0

21 release files

8.3.9

36 release files

8.3.4

21 release files

8.3.3

21 release files

8.3.1

17 release files

8.3.0

17 release files

8.2.5

21 release files

8.2.2

34 release files

8.2.1

34 release files

8.2.0

28 release files

8.1.7

28 release files

8.1.6

28 release files

8.1.5

28 release files

8.1.4

23 release files

8.1.2

23 release files

This release

8.0.10 This release

13 release files

8.0.8

13 release files

8.0.6

13 release files

8.0.5

13 release files

8.0.4

13 release files

8.0.3

13 release files

8.0.1

13 release files

8.0.0

13 release files

7.4.6

28 release files

7.4.5

13 release files

7.4.3

13 release files

7.4.1

12 release files

7.4.0

12 release files

7.3.1

13 release files

7.3.0

12 release files

7.2.0

12 release files

7.1.1

12 release files

7.1.0

12 release files

7.0.8

12 release files

7.0.7

1 release file

7.0.6

11 release files

7.0.5

9 release files

7.0.4

12 release files

7.0.3

12 release files

7.0.2

12 release files

7.0.1

12 release files

7.0.0

12 release files

6.11.2

1 release file

6.11.1

1 release file

6.10.3

1 release file

6.10.2

1 release file

6.10.1

1 release file

6.10.0

1 release file

6.9.0

1 release file

6.8.2

1 release file

6.8.1

1 release file

6.8.0

1 release file

6.7.3

1 release file

6.7.2

1 release file

6.7.1

1 release file

6.7.0

1 release file

6.6.0

1 release file

6.5.2

1 release file

6.5.0

1 release file

6.4.0

1 release file

6.3.0

1 release file

6.2.0

1 release file

6.1.3

1 release file

6.1.2

1 release file

6.1.1

1 release file

6.1.0

1 release file

6.0.0

1 release file

5.0.8

11 release files

5.0.7

11 release files

5.0.6

7 release files

5.0.5

1 release file

5.0.4

1 release file

5.0.3

1 release file

5.0.2

1 release file

5.0.1

1 release file

5.0.0

1 release file

4.2.0

1 release file

4.1.0

1 release file

4.0.0

1 release file

3.4.1

1 release file

3.3

1 release file

3.2

1 release file

3.1

1 release file

3.0

1 release file

2.0

1 release file

1.76

1 release file

1.75

1 release file

1.74

1 release file

1.73

1 release file

1.72

1 release file

1.71

1 release file

1.70

1 release file

1.69

1 release file

1.68

1 release file

1.67

1 release file

1.66

1 release file

1.65

1 release file

1.64

1 release file

1.63

1 release file

1.62

1 release file

1.61

1 release file

1.60

1 release file

1.42

1 release file

1.41

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

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