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

Uploaded Source

Built Distributions

thinc-8.0.0a21-cp38-cp38-win_amd64.whl (918.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a21-cp38-cp38-manylinux1_x86_64.whl (937.3 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a21-cp38-cp38-macosx_10_9_x86_64.whl (958.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a21-cp37-cp37m-win_amd64.whl (911.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a21-cp37-cp37m-manylinux1_x86_64.whl (946.0 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a21-cp37-cp37m-macosx_10_9_x86_64.whl (954.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a21-cp36-cp36m-win_amd64.whl (911.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a21-cp36-cp36m-manylinux1_x86_64.whl (948.4 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a21-cp36-cp36m-macosx_10_9_x86_64.whl (962.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a21.tar.gz
  • Upload date:
  • Size: 575.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21.tar.gz
Algorithm Hash digest
SHA256 3b98d5e791dcecfe0555c87714ac4b498b1e61bdb1fd1b1bae98cabed0c57429
MD5 f37c9cc457210411063653aef0722b3f
BLAKE2b-256 67579ea8f7f3ea587c5e89798069099e208924b243134a43bba37942eb5e7d14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 918.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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5fa2d8c61208b08efcbdc20710658ba6c8d2cfe63b83692b18e00db62015fb7f
MD5 4cf504a1c1b1fc11b98c39f7c47d77cd
BLAKE2b-256 c9bc61d2ba9386706caa4c0eb27c943e4234c693aaf5123bd12e9accedd6f4b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 937.3 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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 55f9ce34589d185ff53446a337b262ac05e0d0ad79450206ca95c793eb1fe8ca
MD5 29a4198a8cc12ab6f6420298dfd44133
BLAKE2b-256 88be8b6b94be5113ae95bdee9a28618ab98f5d7c47d33230f4ca82c1e68796ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 958.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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dcbff54c17f9da578d40aebdee21750cf129d753587517a37400735ca5b93215
MD5 ce470de34a83ad9d6b05ec8a0fe100ae
BLAKE2b-256 8bb771e87bc55f6cfab4eaef82091ae354e65f0c7f14fdb5d94d880f2e1577f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 911.5 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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 cc7328bc4f5fba67147d39ee74eea3d37e0c18f7f63d1a7a164726df89fbff5a
MD5 a2732dfe31b8e6e702686336c5b63d1e
BLAKE2b-256 1156f0240837dde4433ef270f8b4f81c9100ca4a850ee968d34006e1c52efcb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 946.0 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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e062b2cd92277aa534d66b2a8e0bb7f4c562b43d4672bfe0b4c39ea2301ccb49
MD5 422221f5f0c8f6abf9606843a4481c3b
BLAKE2b-256 b04ff74876c5a4c5c82907867b4c0848398820933c8bc6eb8e7b8bf10e3624f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 954.8 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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4886a2bcccc4cd8e1ffed463d2bd48578daea21b8c9b4ba7dcb48430a101af3b
MD5 2145efab651da2ebcb3d0bc4464b0c11
BLAKE2b-256 03dd103defc356afa0641795a3b009040e15db36e421a262a019439ccabf18ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 911.7 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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 fe71efa2f961d4f2b532ea2cfcb40127c0e5ec0ea87de7b9af31272f19e8418c
MD5 dba61d62f14af81803203eda7e0c905d
BLAKE2b-256 249138da07956bbf4c68433813ded1117a468d6414ce116121f7afcf2263ed04

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 948.4 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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ec1d7c2a0f7de69b0d70acae09940300810e3af553e272584cfda149398f6b45
MD5 a53cb2e9b695d21e11c159449dad4117
BLAKE2b-256 cf0712f23f94b139dec1e1da411de0c76008ca3786481c472a81ee3cc5d15e8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a21-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 962.2 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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.1 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a21-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bdb073364adff9faec8cd25aa4801ab65bd3cf5ccb028622579f12b9c85a38cd
MD5 77b9bce41252d7cb514d40d155747210
BLAKE2b-256 0309bd560bda1a25f6165c1c6560173f82be5bdcef19aa850efc73fd60c92f63

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