Skip to main content

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

Project description

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.

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

thinc-8.0.11.tar.gz (174.8 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.11-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (635.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.11-cp39-cp39-macosx_10_9_x86_64.whl (614.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.11-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.11-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (636.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.11-cp38-cp38-macosx_10_9_x86_64.whl (609.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.11-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.11-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.0 kB view details)

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

thinc-8.0.11-cp37-cp37m-macosx_10_9_x86_64.whl (601.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.11-cp36-cp36m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.11-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.4 kB view details)

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

thinc-8.0.11-cp36-cp36m-macosx_10_9_x86_64.whl (602.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file thinc-8.0.11.tar.gz.

File metadata

  • Download URL: thinc-8.0.11.tar.gz
  • Upload date:
  • Size: 174.8 kB
  • Tags: Source
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11.tar.gz
Algorithm Hash digest
SHA256 95e766804d9228b90a58659fdb5610d0bc3eb66c28142dea69ac844c6953906a
MD5 a0c214665344630688026b98488d81fc
BLAKE2b-256 00e945f88ff43c2c605c6b5e50c366b4be00736ba3460d953014f11845c381b3

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9f2cddb8699b74a40f0ea74d079efe24900ac36c6da6c33021004583b5d66109
MD5 e8099525d0d9c206da68f86348be01f9
BLAKE2b-256 74143e7a08d5ecf5373c6d38fa9a32b053e1e6333be829d0414dfef6d8dc56f8

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3510fcf92bb1f73edca9a7f5236c63d5441d78b0e51a71517e303955d762157e
MD5 3c25ab005306360256750adba08a53e4
BLAKE2b-256 457c080f34c133f7afeed86a0ee1b40f188a9131132dba5254897c3dc9b76fa2

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 614.9 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d46d654c9b1c1975227742a99f9a8f930b9bb01c3f691bbb889b8dca61e060a6
MD5 e8814725d314c4e8a0738f45be57f09a
BLAKE2b-256 b4e6d9469c2ea71efba143337a6902ebf50846e7b7059bc4eaf040946a19082b

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 20f8f30f644fb7ec8d4af41654ef0e0b39b21ad19ff684283c1982c2a89dde41
MD5 6addd1f3a135951b38e2f3d95e1fb49d
BLAKE2b-256 ce4f5d6dbac8bc0f4d088aecfdfe4d78b7df89b01945bbbc1dac809220daf429

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.11-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 816a7833f0c4b70a25462b944802e55a16d5617058688ab3cae4fa28b5066432
MD5 e0c611eed9fe0481b467510f7581e914
BLAKE2b-256 5410bd53753f95de4eb0c406169dcd669e210113d2b97832ad33d364bfe5f959

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 609.1 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0a7bcd2ef2ad59a8a73645ad9b8796e0ea0626ace5772ec3d312713a7ec59e2e
MD5 f2df29df08eb44377c01fdb1a3f878f7
BLAKE2b-256 5b1b93b020bfa442c463d2ae5da08514d24fca506b0766a4bf7622cf1f550397

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 048506bc49a61b83f092e6221808ced23ae1c12d80c4ef33395df215a9e3e472
MD5 367ccc407c3f52db657add7444ef9b49
BLAKE2b-256 045afcad4c9c8f1e8eb214a3988346005ee13476f97e35eca1b5f363815ecdcc

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.11-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a5232bf0323d3c3f1cec6ddcab1f6936102c4ba1a347737363ffbad3af2d67a
MD5 0614c82bbd889c9cde9aa76e67203a83
BLAKE2b-256 eb210e0123cb941662cb26037156502606dd1590aa2048fcd1c103c50e1dbe55

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 601.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f4474268b99447501f95a4c4fbcdc61d77c2cd905cda17206cae13b1b50a15c5
MD5 1221f17d3de0ae5618e2431f5fe1e8a5
BLAKE2b-256 a3f92119fcc822ccc38f181fc02c30ecd194077dff6ce27309b0a44c00e2531c

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 0a06bf5dbede8885ab5a52ee5923880540214b7efa5792359db74a2321625d7c
MD5 b8a37e03f64f19ab735d6566968f0742
BLAKE2b-256 0047272f511c9a945e4c3d641f8fc58502966d5b89fb3fc86602a885ce71dc1e

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.11-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 586b9199e6ca456b3c43bee7f655ec3b50cd25c38a8bb3fdc9b2e7cba5859a9d
MD5 8e265f44542477eeea676525acb477d9
BLAKE2b-256 ac1b6e3bb12c65c9a414b4965aa0c9ab774d790117375eb806b0c07aba049557

See more details on using hashes here.

File details

Details for the file thinc-8.0.11-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.11-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 602.7 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using 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.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.11-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d7b3b243be5b64a96f494f014136442afb51e6f0b543de42c928e5e58d534c22
MD5 6099f812e75952e906d4f619f6cfaf4f
BLAKE2b-256 f18f64f637e907c98519777110530ccad6d9f5ef5b3f0f1e0f32fff339f84bbd

See more details on using hashes here.

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