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.0a11.tar.gz (572.6 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a11-cp38-cp38-win_amd64.whl (915.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a11-cp38-cp38-manylinux1_x86_64.whl (934.7 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a11-cp38-cp38-macosx_10_9_x86_64.whl (955.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a11-cp37-cp37m-win_amd64.whl (908.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a11-cp37-cp37m-manylinux1_x86_64.whl (942.7 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a11-cp37-cp37m-macosx_10_9_x86_64.whl (951.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a11-cp36-cp36m-win_amd64.whl (908.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a11-cp36-cp36m-manylinux1_x86_64.whl (944.9 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a11-cp36-cp36m-macosx_10_9_x86_64.whl (959.1 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a11.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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11.tar.gz
Algorithm Hash digest
SHA256 9ab3b4abe1bd2dc355e86ea95d982bfbdeab582b7f363d6bba1de4c0a53ec5c4
MD5 3777218c4034c52c2d640b4f22e8e937
BLAKE2b-256 6e59e0a609e54adfb8ec30fc1926f1d31aef85ba3aead5fcf2e78228dc3c49f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 915.9 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 34dcbc4fc2f9fe284f79a51dd97cc90f28a80ad8f4672e7094b2a941d65b4488
MD5 1f6c8010637e9bcdbcfc445c8b9f6685
BLAKE2b-256 6752bfadd4112b8a4ae9994cf10625415cb83c6a92d1378e948b0c782aa8bc42

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 934.7 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 51be680f37c1fd1c45e3110acc19f457196a4276d76e64ce92782c617e236409
MD5 d5487ba6cccbe5f14beb43ce0075fe34
BLAKE2b-256 cb35d5dde9632eb3116d938db8b9db7e9fcc436a4882c709d78befecbc59a743

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 955.7 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cebc713a1761848d514d4ce09008580fb11b832447e9838bb3aefc2a38d4070a
MD5 eb2dec9dd2187028abe65878244cd7c6
BLAKE2b-256 1003460788ffb7bfe01afc22a495ccd37864ea944af43eb3e90e770578cae2bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 908.3 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c9c23da8342ce2fde1b77e9392ace0eb747600acaa2e36b5791b18a2e3774196
MD5 b9c30be7734f97c73e4dc81037c670f1
BLAKE2b-256 18aae331253928a0927b6bb670fb43e2b29f20cfd591a570884be9ef524d718f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 942.7 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 58655cca3308b247e823306a2caec010b9f6dac77ed29f48700b8590619947ac
MD5 0fbee7aa87545dc7116782da61fda379
BLAKE2b-256 69ed4c5f08c5859c7ec16b0c443deab28a7c329cd2312d4dc2cd5f858f08797f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 951.6 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d1199c43543591b7504c80a980330a376d4cecc1a60ea42aff0a92d8273858a1
MD5 8e35885e272a74396d43df5239a5b24f
BLAKE2b-256 f2404c2f8109f05df41b72f99016431a8f2d595acf1838afb1001a01bd2c9fd9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 908.5 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 67cb9f17a6dd784cbdee6202cce0a6a5710c7ff4b8398bb00d0570af5167c49b
MD5 931dfcb4b447576722fa950aaa4a6028
BLAKE2b-256 f5ed5adcd7d46d7f2d16d873560049b27c052b0cb12281c228c731ec3035e2df

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 944.9 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0480e1d7845b1f4b1ca5bd3e44338ae8b9ad1bfaa018ea9180a1475b24e94a02
MD5 38bc0e98c2c3420346a12dd2315760f2
BLAKE2b-256 1199f48a6297e3fdaed3b9566e96ae8eaa213326661a22ad2695c557771a68b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a11-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 959.1 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.46.1 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a11-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a5683f854746d805a5e0b7e1829581364dcb19caa610d402fcc27ae939ff0ba0
MD5 18eee9989b1d5f330b3ecc5d2f58294c
BLAKE2b-256 7080925abebf34b6c2725652d10de0510b0cb39f0a7b0ba7a1de3643996e4031

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