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

⚠️ Note that Thinc 8.0 is currently in alpha preview and not necessarily ready for production yet.

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.3.tar.gz (624.0 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.3-cp39-cp39-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9

thinc-8.0.3-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.3-cp38-cp38-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8

thinc-8.0.3-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.3-cp37-cp37m-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7m

thinc-8.0.3-cp37-cp37m-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.3-cp36-cp36m-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6m

thinc-8.0.3-cp36-cp36m-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.3.tar.gz
  • Upload date:
  • Size: 624.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3.tar.gz
Algorithm Hash digest
SHA256 c370a7a46d01b588d8d5f99d8d5e36b3cbac4512638356fa430f7f52bb3a8897
MD5 bc1d20f41ce2ea37a58f08031e03a169
BLAKE2b-256 a5ddcb9189de626e8b3c201fea66af03cb4b8d45b326db6d40f2039553751167

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-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.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a625900fdb978e8834eabf68be099cdb487bf637c98c8fe8161a1b6e41def5b7
MD5 627609b8c090d141acee231932145ae8
BLAKE2b-256 074f44f902c57e5b6b0badf958d1d83e1cfff44b38d65088120a2ed840656776

See more details on using hashes here.

File details

Details for the file thinc-8.0.3-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.3-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c842d9432018564f8289ac19fb71ed9311a13b9a002ef88f92373158329f45a4
MD5 f55e9600c0ac3e5dece9af23eef07450
BLAKE2b-256 bcfe442e2eeb58cc41a395fa2cfa3a5cceec40ad8ff7389cb18a88e28fffbfc3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e9a07b1f1ddca26b5594234cbe9015b055d95b2e10796c66182030282e2f485b
MD5 e648a00dea427ed09ae018c57d1cfc66
BLAKE2b-256 7e0d14834ba43e241954214fc5bef584a5c9588826007a1abdc7945b1db7a9fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-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.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0a08043a664448a3768f68221ce2a60f331b730aa32d15372e07f3d90bf49765
MD5 7f44fe0af3baaa5055884666184bde40
BLAKE2b-256 2d072117f2f557acaa0995a19a4947106cd00093f27cd1a664d6c1e947912a25

See more details on using hashes here.

File details

Details for the file thinc-8.0.3-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.3-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e20d73a800afa5c9b7d41d589f086fc4c776dc9d7024f5ca9c67332bb50b6c8
MD5 8939969d10c1ef552fda0e3ad6ef0cd5
BLAKE2b-256 737430a5c149cfb077a020e9495c807c922035febb3af800ce4fe100626a4d6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bd87496ceab914fb0fd646b7ef8542f4c379e76e9dc5271768d089acc7b70d54
MD5 bd559ec2e72897c9caccb0b7fc41784c
BLAKE2b-256 57b1cf33ab8054cd829194fcb57a43e925d84c6e8358b739c46eeaf37916e058

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-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.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 72d04d1c0791ad067f9b215d7c0eccda9376079b8b7170a1d834f68b3a0b1cd5
MD5 c8ba4093e1035c7688c1e2f5673bfc15
BLAKE2b-256 9dfce44d8b7783f112545ef96b6988ec89eeb87dfd42b4a428c1189b7c5d5434

See more details on using hashes here.

File details

Details for the file thinc-8.0.3-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.3-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c30ec3a30125bbffb877ab94792b14807fce1d94a15c8affc0ddfdb7e849ab0
MD5 76fc51ee8762d84c495644c4e5c3adbf
BLAKE2b-256 6187decceba68a0c6ca356ddcb6aea8b2500e71d9bc187f148aae19b747b7d3c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 aa5f64c45067a762d624dfeff5f6a9e7f2cb0d484fe5f0054b77deb7089a9cfb
MD5 c1e7050fe4fd3dfe82bf3e5dd0b39464
BLAKE2b-256 b674b3e5463b8d2b91f944fbe6a8e3d46b69d9f2df5ebe21e8e23f17a967b1aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-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.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 40db2225cd7994372b7748d2be542e206f85d82d950e54fc42dac460795af124
MD5 fa18e37cd7fff4c32aad9b99cae05b3c
BLAKE2b-256 cd779e0e9b7647243f17dd12f29ddf63735a5610ca9b6ead7a23f64a26cb9533

See more details on using hashes here.

File details

Details for the file thinc-8.0.3-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.3-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ddf994fac571e657091c78d4fa5b99c18950d683250226b8be72a212f16f8e0a
MD5 a4e1a91af8da2a6c4ea8c298d95e3b07
BLAKE2b-256 3378125b693ff8eeaf8de5ee65d6b532992dbd93640d878667f5e33beb423b7b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.3-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 739b5e454d5670d228ad62721d0037b0e6cab53adc8b499dcaf6167213690d2a
MD5 a83f0ce8ac2ea3b82c78c8e75ced59a0
BLAKE2b-256 57fd02e26c5497db966577047e9ae003aa8db4d9d193b7239b57e93044a5fb07

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