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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.4-cp39-cp39-macosx_10_9_x86_64.whl (603.3 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.4-cp38-cp38-macosx_10_9_x86_64.whl (597.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (618.6 kB view details)

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

thinc-8.0.4-cp37-cp37m-macosx_10_9_x86_64.whl (590.2 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (620.7 kB view details)

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

thinc-8.0.4-cp36-cp36m-macosx_10_9_x86_64.whl (591.4 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.4.tar.gz
Algorithm Hash digest
SHA256 32016a5be62a2c4b5f86954ae30f8da78bacaa5966ea3ce56886cf9d7c7dcbe6
MD5 f157ce1140260e7e7cee213e6797d957
BLAKE2b-256 551886f68664744e8e6347accd6014e4b616c38b872a34824698d18916b3069e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.4-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/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8fbfed3ed74e2c27133debd6f6912b75b28e9d11153a09be9fcf05d424edd26e
MD5 ade6459221b625080b9b5b7182eac18a
BLAKE2b-256 cdf25f17500dcb020eb0d8189a3f32884e560dd6c0db7c5eddb6f87ee79475ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e47682dcfd8eb3a2aba080c6534439f41dc119cb932f579c58c483144c7be381
MD5 39dd24aa82848624cb962102dc93bab7
BLAKE2b-256 b693cb4020e6702e8f97e58ed3ea04bb33b7c2cc4bcfb8f696d544d1ebf5e015

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d277f0adb33a7e88bb915726332c738899e7700700d11bbec9e2b7b57fd634bb
MD5 261a617e95741ac13e2c8f7fba2536f4
BLAKE2b-256 036b1fa5bb50fa51fe344fb67b51f2b06a963cacf7d85e2078be0f4941a5add5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.4-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/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cb51fb74225549ebf4a9771d9c996b629b31e34d6c4c111a58cc5bae1cf524e3
MD5 623e69733842c1127e8bc2d95116687c
BLAKE2b-256 6c83b13c436a1effd8b82c7813524d50eb0eb7fbb66bd532e284680b2e066cd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70b25331bbb178af46e2f2c7fb68836cc6b7baccfbdb71d6e18a479d2cecfcd4
MD5 338e946ca378ce7ee410e5b59e2847e5
BLAKE2b-256 6be67861cb7cbe6228c5506db96a9ec533d5a2357bd2ccb81a8b32e74a485d90

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1ff35bdbbc386a367d53097bde8f8f9eefa0057967b68098376d60bc276c8d21
MD5 8010847f28bedc28f08ad89aaa2b4e3f
BLAKE2b-256 d7c8774389c8fcb4c40b04860065863807414d66b4f2804501b6baff28e91978

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.4-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/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d6cb7913058e7da625c94b0be0a22d304d548546b2068b5a67ea4894c093489a
MD5 a063c951f3e46fea58e9c6fe1d71d2e2
BLAKE2b-256 1c4779063de1edc3a462b90f1e3cf4219ac8c60abb15b1d2525d8f200d56f70e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c32c1d6101f5d500cf168082c96cc523574d805bb15650fda186d492d9329179
MD5 f71aec3aad8ad994d26fc36bd7449dfd
BLAKE2b-256 55e56820eccc01d6d8b1d87c3bd021321516af572dcd551e41712913f880f58f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6b2505693268d80730c483f406d10eccf000ab08f9e7fe7ce0e4aca8ba411865
MD5 2282906b24966e5192229dadee10c121
BLAKE2b-256 6736e0d35e42e97f74c80ea2defe9f3f8d3bc36f332a75799d94c31827829d5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.4-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/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f1b84880235854d2abfdbebe70996a26f0103fa51eebbe8ec3ca0c3d8cfb9721
MD5 d5d53c95abaab79d12ca3e354ce53736
BLAKE2b-256 76b9221f16362deb76df88141bcc36e107c2300c7ba2cbf25d2ec72e22d7b940

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ff2e340873e6789702a8a03b0dd67b22475782faf0445d8f1c1dc6b4de6ecc7
MD5 09973f4e1e41db9a69aa23f6d361d376
BLAKE2b-256 921381078addf626946b05d1a5cf77d984229ca3738a68dc277a228b45374a6c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 07d2d29327bb8043b61951211985a952862e104045ac9ce739d596680d153e16
MD5 813cf937f77edf77f8ee5802222d6c4e
BLAKE2b-256 cf5bc89ef6ed3bcbf0afba10075b660a9deda646c4994a59332079c71c0a8f19

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