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.1.0.dev3.tar.gz (197.0 kB view details)

Uploaded Source

Built Distributions

thinc-8.1.0.dev3-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.1.0.dev3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (812.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev3-cp310-cp310-macosx_11_0_arm64.whl (694.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

thinc-8.1.0.dev3-cp310-cp310-macosx_10_9_x86_64.whl (762.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-8.1.0.dev3-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.1.0.dev3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (822.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev3-cp39-cp39-macosx_11_0_arm64.whl (697.5 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

thinc-8.1.0.dev3-cp39-cp39-macosx_10_9_x86_64.whl (768.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.1.0.dev3-cp38-cp38-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.1.0.dev3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (823.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev3-cp38-cp38-macosx_11_0_arm64.whl (689.0 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

thinc-8.1.0.dev3-cp38-cp38-macosx_10_9_x86_64.whl (757.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.1.0.dev3-cp37-cp37m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.1.0.dev3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (813.5 kB view details)

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

thinc-8.1.0.dev3-cp37-cp37m-macosx_10_9_x86_64.whl (748.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.1.0.dev3-cp36-cp36m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.1.0.dev3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (808.9 kB view details)

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

thinc-8.1.0.dev3-cp36-cp36m-macosx_10_9_x86_64.whl (749.1 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file thinc-8.1.0.dev3.tar.gz.

File metadata

  • Download URL: thinc-8.1.0.dev3.tar.gz
  • Upload date:
  • Size: 197.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.9

File hashes

Hashes for thinc-8.1.0.dev3.tar.gz
Algorithm Hash digest
SHA256 755763c48d8419deafee7b6c64dd2192450602805896e88c77eb18d976402f13
MD5 11ba61482fbea825f71ea2e7b59c404e
BLAKE2b-256 daa020df72d18155582a07e510751a616f7034a9db2c93c86a57f77c11b72519

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bd19ba01ae8d5042fb9f7fff088a6d33c8a898b829fecb7620d72ce53d985a99
MD5 36d6e7ffa4d2d8887bbb1f081c590a59
BLAKE2b-256 67ab4b1ba32c26e7eb338be98e53076098b3918befe290297eefc7a2a7ecd2ba

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aae08daa1dc2ddf02923cc2f8bb5cf71aa1d3cc0e8f7cb34e9ec7f4d853c9ed3
MD5 30a480a588cf609256d8a6bff49d941a
BLAKE2b-256 b4ed066355ae51cd4f9366446c17fcf993e559b1b07ab8660f0da05a2774f1eb

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f5153972e272ea33ac9256be08fe1963c11bf6cee28bc3dcfccf350ab962b5e
MD5 3b4334af068b6cc78f1b1388f4fd7395
BLAKE2b-256 9f716a0ffce569557f44b0af864ed30871e5abdbd6aefd796bc474798f075326

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 29f007ea7a0969215e6305d869298669eede81ff6d3af6ab9e1dba89a12d20dc
MD5 c8304f88bcde6c01f8bd61068dcf9b35
BLAKE2b-256 e86d1c2d01f7133468f80fbd85e30c666ec769910a64b422ce0c2bc084f65b3f

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f42ab5c13b32cc721455b7933937008fe473078e816b39c80c42512a728bfee5
MD5 325cddbb979ad360f04bb2d1103cc3a9
BLAKE2b-256 85946fd599894bc78d10a7bbce8f65d1e52a876dfc1a491ab5133ad68fd24307

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8038047b5a52a22e99f27cf8e3a58498d03d201a687935585880518b2819d3f
MD5 6206adfa64458251066a4123b54f3d66
BLAKE2b-256 f033925f3f734a38bd81934d9bc8cad12874c52616fc472156307e5662ba9be2

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d0bad0d294a9cdb46dd6e3e6666f199c594a98332ad5646184594ef7aecb97f
MD5 9930c06c2fd5cd85c14698a0d2ffc280
BLAKE2b-256 f64ac3df9673c26a628e3e0ec4cf9671e2f524f8ca6c9f7f230899650c503123

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ce809221400e1c62c62b333393a8d9f56cea85c9aa7274bb63bfb8b51cab0c31
MD5 75b3b8688c04578c6f4a5c938aedad75
BLAKE2b-256 7ad89d59880faf34ce6770b6a47c18a31302f9eb2800d65af7653b5c990873a3

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c6ecb7015fb165012827a25e5ce88baa2123a7157aba1b813003a049fadd8e67
MD5 bce8f36b05a3986b80aaef967ce903b8
BLAKE2b-256 7a8381d1010a27d3b3afe3ac7b77b3d3755c997beb24676dee56551b390a828b

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4d9e86cff0cbd873de681c134fc715b9d1f2e5adabf789a7f8e43388f8417517
MD5 f223bc17cc2836030c22c3abb9ec80c8
BLAKE2b-256 a8f4943c0ae1978a29c5ddfc8c2b85f43c2531f3cf95de602ea2f7e81ca90b02

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c4c58ee160d440b0cc69a555c6acf1594d0e99a86dd0a763143956354132c2b
MD5 cf015d019b6d4fcc963fa9e9ee436e8a
BLAKE2b-256 468135c908f88827f175bdbbd7c3b72d4ea061ae4aa92b0c356005e9979184d2

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 168a75eff72570645ca108206a971a96b408a0e98d1cc088f3b535c345d4dbe7
MD5 a396408c5c333532e97e08e3292f2e2e
BLAKE2b-256 6c5dd6237dbd295fa585dfdcab9d1fba9e39edc95360860ed13c234eb97b8994

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9da8d238e4b3a1daf418e952aff19a6315bd3e9862b16a4783dce16810cd8489
MD5 ce85521dfc70d0847fe9b4cb58cc19eb
BLAKE2b-256 310c160915035e70b2643e1dc3bd15bd0f66d6e2cb98e437fabae5d2d2b24735

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd8357d6ae26b31769a724e877ef9c59a8c414b46279c2ba5215cfa49bb8fa18
MD5 c2adbd0a15597a5ac9b51c542c6e9beb
BLAKE2b-256 1ce66d45f7ceeda3fbf5d7130a902766fb04ebb71057b0a6f7aabe36db14e96f

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a59d212d7b37fc002b5e2e273574aa15dd725e54aba08e615e185b89af0344a2
MD5 6c3f043bb4561600d4ed2df87fa3f774
BLAKE2b-256 1e84eef8817429a6f2f0eb244867898ee66a94aa7e8eb83d6869425dca11d650

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c64fa94ad635774e8c51e1b3862c1d533bdd57180f58f637c5eca3557e0e3405
MD5 87aa100ff9f2b7b05c375a3b7f1e52c7
BLAKE2b-256 47cbb3c6fb5f2267dba0b9b99e5dc03d83f8dad00142e9c962b44e5d735e1dc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 affe6cec3040940d049e2c770241aa9378646e2460868739a282d92ed616a695
MD5 fdef5ea5eccd3ffbf9224930002f4592
BLAKE2b-256 6dff34e3a05647fb32fe12d56f114f0d02a0413aecd4f5c10d4b11ae3eac8ddb

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev3-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7864906d8c3a0301ea67340fdd49861ec7fc406f83237b27f11ec28c9c803bd6
MD5 417445f4a0689cbccba8ac5828d30c97
BLAKE2b-256 4c318556b7579df83ae484259373fdba0076919de4f78f34438e40579cd31a30

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