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, including JAX support (experimental).
  • 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.

pip install thinc==8.0.0a1

⚠️ 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.

📓 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, cupy and jax.
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
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.0a13.tar.gz (572.6 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a13-cp38-cp38-win_amd64.whl (915.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a13-cp38-cp38-manylinux1_x86_64.whl (934.2 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a13-cp38-cp38-macosx_10_9_x86_64.whl (955.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a13-cp37-cp37m-win_amd64.whl (908.0 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a13-cp37-cp37m-manylinux1_x86_64.whl (942.4 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a13-cp37-cp37m-macosx_10_9_x86_64.whl (951.3 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a13-cp36-cp36m-win_amd64.whl (908.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a13-cp36-cp36m-manylinux1_x86_64.whl (943.7 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a13-cp36-cp36m-macosx_10_9_x86_64.whl (958.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file thinc-8.0.0a13.tar.gz.

File metadata

  • Download URL: thinc-8.0.0a13.tar.gz
  • Upload date:
  • Size: 572.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13.tar.gz
Algorithm Hash digest
SHA256 44cd71cd2b1d1efcda12a48dced08d1840a96d21ff3b2348031877018590cf79
MD5 d9ad8d6f177680e2a451d596f227992d
BLAKE2b-256 94ab3bba2653e59c96468ff9731dbdcbc1c83e548076f2475bfd34647945c49d

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 915.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e1f6b3d58029bfae98ff02e961d7f7141c685823bbc4598db7932607e220f4da
MD5 2b0bdb464c7d2736aee7d38971fc11d0
BLAKE2b-256 d009d957434982f2b833acdf79d2c0797e606b4f38166bb0fe81d4b1d626696a

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 934.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 24909be284fdfb5c3d6998c951215acd6709cb9b1b63400c875e7063cb4615ea
MD5 d3ece28a75fbe3fe755a320fa303bbc5
BLAKE2b-256 5ccb3ec60d6e3653941331a1fa8ad746e7d0e69a42b980fd9e2cbf31ca7b775d

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 955.3 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e091cfc6dbdd3a2426a6b7d561a33e1506d4994bdbb1599fbfef6eb284473a4d
MD5 b7db7f3eb73a0142d2ba1354eefff0ea
BLAKE2b-256 4ea79e1f41d95e2ef3dedc5ae40afe2fc3955dc9668637fb468bd33fcdfef072

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 908.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2e95f27770d4e37dd0bc4203348a72d4be13c00ce5f6082ed960b9b8e33f6887
MD5 2e4830d69767ceb3f41a384929883916
BLAKE2b-256 78afc55755196bf249415e2d82fca5af47aab6d2aba888405aa0f552e30becd7

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 942.4 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c1fd39e8a0c7f9de9c0ce079e0e8e9f8d1c3be8927433ba06edd7c7bfe68f5a5
MD5 d57bee6734ea84f1e63687dcba2cede1
BLAKE2b-256 2006abdeeca4afca996ecf946ff5e8f11b520db20bedcf88ccc7f4b5673b7cab

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 951.3 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a1e1890f3baf5cbf9fcc895ed6cef7da3a521fbc4fb81ec88949504b26f2e17d
MD5 c819e0c391d130e2f7f96cdaacba2937
BLAKE2b-256 78e64278cad1124bed305d25014b3457298a05f5296f7a0c8904ebaf2fa06cb1

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 908.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1c032c783613ea18efca0949a01c67be3de042ba50765fc6b58d3dd1d084a985
MD5 0cee28f8274d2d3152f894dec7415929
BLAKE2b-256 4ef6a5fe9e1c5c85ad1d16ffe2d2279bbc3f472e60283ed4149422bf07f063fc

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 943.7 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6db9fd6ad9976f248573461e98a151a1c38c2069709c162545460eb2e7cc8e38
MD5 bdfe55fb4765f60c94e1c2c92a6814c1
BLAKE2b-256 ad7a8c2fdde0579ec99d764ca536058a6a9f2d2418a8ad18f5345f600f287eef

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a13-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a13-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 958.7 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a13-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 54d46d90f5e4881543925c567a25f638e914fec958910f89d9bc4280a5116e93
MD5 72ec4230dcdfb3ec5776c86d0dec99af
BLAKE2b-256 13edae3dbe35f3a40a49fb0879341f3671d8e6f717b80d3291bbda5acbe01354

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