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

This version

8.0.9

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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (631.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.9-cp39-cp39-macosx_10_9_x86_64.whl (612.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (632.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.9-cp38-cp38-macosx_10_9_x86_64.whl (607.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (623.7 kB view details)

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

thinc-8.0.9-cp37-cp37m-macosx_10_9_x86_64.whl (599.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.9-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (625.1 kB view details)

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

thinc-8.0.9-cp36-cp36m-macosx_10_9_x86_64.whl (600.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.9.tar.gz
  • Upload date:
  • Size: 172.9 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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9.tar.gz
Algorithm Hash digest
SHA256 ec413f5a14d277ee354841c48bb0d5c3310868c797918058218387b0423ef1b2
MD5 b4eefddbbb2f1dd31e00778fd4ede567
BLAKE2b-256 23e63e6af2be52604f38ac0e0698ee4709b4894ccd316d765c9f7f52de577b95

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 129fbc67b9021aed99245e54d91f07918871e08ad901d8074a32033567dc2431
MD5 bc2565f270a1b571a9116491185ea2e4
BLAKE2b-256 ff1b2d3eda1ac57708d1bcc11c99dfbe1247d04551f0f7c65a2e2e04e7ad8b22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63f851941b4eb50c96b56e8baf75190e47d9563f62854d7a9fd242f4953872bd
MD5 0b72c2364a2108404f169f59af2811d1
BLAKE2b-256 1d6d7a3462cd7d11f036603b283495776ab316caba18c1c79f05b50b1a550010

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 612.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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e3b93e6bb52e001627b2f2b03ec1e610376a0d8fb98201b3b958f30a7a95d311
MD5 4cdf20754347b60102923e59176fc3f8
BLAKE2b-256 123779d20ea976b44febd11e4eed27b4e14b0573aa10097707f38474979a7338

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 49180b7da1ad3e8df31cc078e891c4794d16c9caedc69b55a064eca94747c637
MD5 c8433187629d7b532f2fa2849a56d158
BLAKE2b-256 c6ee3224378773fbc54a60981fc7f6e0c40cc80382fcf23d92a1a9aa5f47fb78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73b963ef96d4bff07f310f8f9ba69695ba6d461748bfff1e47caae84ba0151bb
MD5 7a721d9a8be39d0b21f302cfa25dbf38
BLAKE2b-256 84303e179c0030145771aedadf4c1640a82a5db8c62e8175e7086f6692b3c7f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 607.0 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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f5e8f6330cc5cd25a54c355664e2ed4053f5d5c3719102ac98797db4ad6925a3
MD5 910dee2fbeebd0cc3ac8bd2976947f69
BLAKE2b-256 44f593479b3b9b910a7633a4a812acee919e7b4ede344a8efbe5fb34651ea3a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 e618022363f232d68943e51bd7ba6688d67607e9c9cdb4be47e8284f0e99d3b4
MD5 6ff11d4c403079d0e0ec04e56f1b1fb6
BLAKE2b-256 01d6e61b485570de116bcac1ba9b24aeaf529ac5ef8dd41403334f90344155c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d274165b12a9b12ddd531488981afc6aeafb2ac4496d2518b430ef41ecd04eaa
MD5 d5322023c11d448db7d618c653250cb6
BLAKE2b-256 593f487cd7ff7e2ecde3e9ec597742bcdeaac519404959c90175f4579539b8de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 599.5 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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8e41ad8537b7d2b0d8f8b5382738d1b37fff189f7aaaee99750aa0c17fdf5b28
MD5 82f39bdd72ed3d3ba2771b683ed954c1
BLAKE2b-256 258031a004fe0f2bfd1c106b0cc65bc18bf6b8febaedd384c32440ea2e13302c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 0f8ca50a52ce5ad27297bde046821f129134a36bdbd99b464c500f37cdd8254f
MD5 7f1918a3aece1a6c946fbd55d9ebafa4
BLAKE2b-256 3cbb418cf886987e4fdf971a9443df581cdd0433a69f13ce3b2fdc59a5ac8a68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.9-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c060d5c7c121403b21e175df8aee93c3359238687c62dea6e1f904b9ea5a361
MD5 ac20e9c91b744f515533ae4a3bafbe21
BLAKE2b-256 b793c72600a8c4683b9da3932ab8e2843d20664469e0c00460f9dd7c989171f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.9-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 600.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.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.9-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f797fe59987651f77465ab9977acec9493e7022ce8d5404d5136db21758cc43f
MD5 66c2f9e9a07c43f86d4eaaea10b99cd0
BLAKE2b-256 dd67b99d27c689c5dccb924581789c1996606683d50cbc893d6d07940db61b9c

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