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

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

Documentation Description
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.16.tar.gz (189.7 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.16-cp310-cp310-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.0.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.0.16-cp310-cp310-macosx_11_0_arm64.whl (584.2 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

thinc-8.0.16-cp310-cp310-macosx_10_9_x86_64.whl (648.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (668.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.16-cp39-cp39-macosx_11_0_arm64.whl (586.5 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

thinc-8.0.16-cp39-cp39-macosx_10_9_x86_64.whl (645.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.16-cp38-cp38-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.16-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (671.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.16-cp38-cp38-macosx_11_0_arm64.whl (581.9 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

thinc-8.0.16-cp38-cp38-macosx_10_9_x86_64.whl (640.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.16-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (660.6 kB view details)

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

thinc-8.0.16-cp37-cp37m-macosx_10_9_x86_64.whl (634.4 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.16-cp36-cp36m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.16-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (662.3 kB view details)

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

thinc-8.0.16-cp36-cp36m-macosx_10_9_x86_64.whl (635.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.16.tar.gz
  • Upload date:
  • Size: 189.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.16.tar.gz
Algorithm Hash digest
SHA256 4bc781a51a8789ac402b36ef2e07d17636d12a7890002754f8d70f05bb68df51
MD5 9d4d401197e8213977d3477cc7fb030b
BLAKE2b-256 0211b358f7529752eab8961245a1b69b79355ed59660d1455a588a7f449e47d7

See more details on using hashes here.

File details

Details for the file thinc-8.0.16-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.16-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.16-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1caaf36b2dd2d0281e0ee0e68e496a875b64d52524b31ae3771d73431aa3ba11
MD5 87d6cd519b6a5ecfc2c749303db16ee9
BLAKE2b-256 6b55c646078bcc478512571707dd895dea089cf705b2add201d590cc5debdd6d

See more details on using hashes here.

File details

Details for the file thinc-8.0.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 90a38c846c8597ad5636f9c50f8f6ecd9655662d6fea14b28dde1d91e71591fe
MD5 fb7a84b794b893fb242709cde2c65eac
BLAKE2b-256 0ab4d44f2214b373a21c18b43886d645220d8dcf7eec19f9340d0e3ba2b30f1f

See more details on using hashes here.

File details

Details for the file thinc-8.0.16-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.0.16-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 122d29a289bc8bcae75dbc0cb0d382256ef68ba6946a44891cda5ca9a071aa3e
MD5 3abd3f4cfea0fbc54809084354fe2e7f
BLAKE2b-256 822202e9af1ceb1444658b0b63cb852a222455bc3d267fbb2ea4a24b72949d8a

See more details on using hashes here.

File details

Details for the file thinc-8.0.16-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.16-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2a57e163205c73df8b0507fc74e06b34b74827832541c1d41efc1975b6fcb818
MD5 726dcf31a3c82266ec51a9bd43b6d875
BLAKE2b-256 efe64bb10cf9c0b55fd314398a4c1589a773f586fd24931db986b052455cf4e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.16-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/4.0.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.16-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5b14aa6fddeb15076222f8df84a42050e49e9615e0f4e9a6df454f26a70f23d6
MD5 d6441fb7224b0143264c6fb263b69f0e
BLAKE2b-256 c85291acbe07838499e5a1750fc00b90813c76e7d80467f6b206641d77f981b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 885945d971f65432f2e06796dd9e1632aa84530e2ac2f0dd3ac57e71f2cb140f
MD5 844628f1426ad19d403b63ba4a6fde51
BLAKE2b-256 6f3f6951ef69d31eb304530ef62313eabe9921eefb7ce1a65d04c38aaff1cb2c

See more details on using hashes here.

File details

Details for the file thinc-8.0.16-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.0.16-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae1c765dc7ce87033f2137ccf33b75b8ba1493320ccf0eea11e1a144fbe2450a
MD5 1a3ae7dbb78de2eaec11f6b0aace729b
BLAKE2b-256 918f40ee25bd4e36151b8941f9d0e96309b76b131d17ec0f3cdf636aa2fe6ae7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ca13f31a35d62b16546cee6f6d874e6a64481be02aa6fb7f0bf7462b61cfc2ed
MD5 7cfed048e129b9d931db763ed3f2a917
BLAKE2b-256 73e132497db4126b501799ae782d4ca150b8be04193b0d512d34e53b3d168275

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.16-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.16-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 151e2667cef683a87aba4ada41b1ef3e8a79417b8e2151d8832dd2e65d611693
MD5 663cc52a313732122ea989fcc79f3e15
BLAKE2b-256 1c5a4f517731f613a0246723b76f74118c8803bff9cfac36bbb0f701f92a15f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e544febd6adaa936e57432b1bba84328d51b6071695044b7844c63460c048f97
MD5 d42730ae9598758c41f14f3927f000a9
BLAKE2b-256 b7dadb6ce7f824abcd9f505ce22985cd04716429a57a258dc079b92ce1c48fbd

See more details on using hashes here.

File details

Details for the file thinc-8.0.16-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.0.16-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 61f57435206d2a1c9900d5c9eb754ec4040e55ef79077cc9a88fbb2851d02944
MD5 356c18b8a8a0eb15d06be586b318556b
BLAKE2b-256 de840cf0f3aa3d042d55d1461328501f9dfd9d79c0c9d7c67602ccfa911e4897

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 05dbe98419c226d3904d178f968873f6be3d36dd4c6ae8baf716f5ba4a4a7fd9
MD5 55e7bbfc1491ade3c9c352e61ed540e7
BLAKE2b-256 2a6acb806c0782c8bcbf61083571f4091b3861930ed5a9adcdc2a7933b996bf9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.16-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/4.0.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.16-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 72888464081460a6764fcce9bcbc49e5d0ce99658993f01044051f7f8383e481
MD5 8ea88ecf61e24027de42234f5126c3aa
BLAKE2b-256 e87fbb4368475a31af9f1f69cd2d4ad0c30ef833ce20f47b4dc3f5f180a274f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3bba61bddf1c26edb131b9433ec20b3dd580b19f02a2bfa4d0abe4816fabd63
MD5 773390547d03cf64b543561c78f037e8
BLAKE2b-256 6824519a7bdeb1854c66963acf3cb36369c4ee55e2e50eb1eaaa5f122a3ec943

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2fca903aa2844bf7caa4e3709e1ffe193e8dbc2834e1cd8c1534707316866546
MD5 fdcead78ad4ecc2b765cd19ddb1eff1d
BLAKE2b-256 6b015117ef66e35b1153cd193c59e8c82009b6da2859838a63751c8d745c7cd3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.16-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.16-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 30f5d16491e5c476b0712c9501d6c7b28fbdb046a321b1397cf5be527442b505
MD5 da8af1bad2d93d2d13e0b01c7824ac03
BLAKE2b-256 77e4980bf6fd41242340043b850f7c96845feb95902c881220042435b666bfd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24ebf1ff4057a7844e0ad31588128a81b7f746984f8ba5f256262091d536cad4
MD5 9c76315a8653e9b6bcfddb2b35b8cb13
BLAKE2b-256 2f9c76aa006d7826baef36d951e3120812672d1f32ded400186a6434c43cae33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.16-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5a2136c9c3712b0854437698932b48e532c1f3bbaaea7c048eec79fc4901f22d
MD5 dc118913565e1294e82cc4ec5b2fb325
BLAKE2b-256 445712a4d6dce4586aef3bae8c2eb3c8c81189a3955e793919e5480cb1b2f111

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