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

Uploaded Source

Built Distributions

thinc-8.0.0a16-cp38-cp38-win_amd64.whl (916.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a16-cp38-cp38-manylinux1_x86_64.whl (935.5 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a16-cp38-cp38-macosx_10_9_x86_64.whl (956.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a16-cp37-cp37m-win_amd64.whl (909.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a16-cp37-cp37m-manylinux1_x86_64.whl (943.6 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a16-cp37-cp37m-macosx_10_9_x86_64.whl (952.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a16-cp36-cp36m-win_amd64.whl (909.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

thinc-8.0.0a16-cp36-cp36m-macosx_10_9_x86_64.whl (959.9 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a16.tar.gz
  • Upload date:
  • Size: 573.8 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.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a16.tar.gz
Algorithm Hash digest
SHA256 894177d754a8a96e1798a6de2f2c2d8d3a9a12178a096f9cd375fab484c6b75c
MD5 9dec2a97e3a1ac63d1e5f9498eac00c2
BLAKE2b-256 0694cbaf7d64c1c74824a56707fca9f4e4ce075c0b115850da50b06276eb0ee2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cd0be9e713232d516b159661b41b7c089528afdb46173c1fbd8bd9eea4a90a4e
MD5 77985d5f4d96e75f6de7a80d53bc4c72
BLAKE2b-256 f327b540eddb475551c2157161646c424645da1a4477fee9a36fd34c9a630ae9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e305c935c81a787914a4d4aaa041fd31bfaeade0bb24d0fad21e431c8212f8f0
MD5 6a5822df6baa0b32eb3efb4171499f93
BLAKE2b-256 21f7059a61eb5a75ee3d891c4d4f207cd75d547acc6274d6984687e59ee6b466

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2872e80c98cf277284a665a15c95c1eecccdbd1fb141a7549f0b9757176a815d
MD5 a9512deef00c0bc4f13e0ab9918aa1d2
BLAKE2b-256 79bd741643862fd955ebd62a06fd7e3ca3281123da998f0487e6a978e1c24a35

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 31d21ea30e60aa443ee9225f083a5c9bf5c4763cd759f6a51c0187259434250c
MD5 76e7c091beafd89b71d9ff37c783876a
BLAKE2b-256 1dda35e0ad0678463def6243e2241af830705a99abcf4b9d38728aada28f0e0f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bb83bf29756e90abce0c49ae787f2f5c1fe645b6170075e2f15f8cd300bc97fd
MD5 c5198d8e3ead955c8d36985ba70ab731
BLAKE2b-256 70a76b5d4acbac60e3d5b8aebe081d68a1dd216b6887ab8ea033fb98426ce8ca

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 46459ba3694c163f2046e5cbf9e03f4d0836cd54833c74df05e49d2602728f0c
MD5 8c865587ac369647c1923700b5117676
BLAKE2b-256 088097b691bd0970f2d6701459f138e6d3278a9f030983a29561f2587f9ac2a9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 fd065e074a46cd7236fd430d12471c30baf67a15ca129d4fb6770bd6c0525e60
MD5 e2403f2bd6cc8e75b82796610b0071b3
BLAKE2b-256 6d407e238a87d64e289d9b26d8b60916a96fcce54684f9d5daa64441acf3aca7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 336ee54875f8a6c282f9a396c7a14c4751ee6aac5e27c43bd80f8dc27100c67f
MD5 7fbe754e073dfaabe2d75af8a1030570
BLAKE2b-256 0efd21da725e7242796a18fd71b2458dcefb91dcb6af6e11e7dfdef7ef15aeb2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a16-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4301ae87da549480a1ccef44459724484fa3c1eb4e10ce256887df03c7915b4b
MD5 13452d23aadef1cbe79cf8e50ac2cda3
BLAKE2b-256 a2dc82a6a7ee37088864292425d5232139cc07822d36afce4e0606726a41d194

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