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.
  • 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 --pre

⚠️ 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 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
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.0rc1.tar.gz (568.1 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0rc1-cp38-cp38-win_amd64.whl (907.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0rc1-cp38-cp38-manylinux2014_x86_64.whl (964.2 kB view details)

Uploaded CPython 3.8

thinc-8.0.0rc1-cp38-cp38-macosx_10_9_x86_64.whl (947.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0rc1-cp37-cp37m-win_amd64.whl (900.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0rc1-cp37-cp37m-manylinux2014_x86_64.whl (956.9 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0rc1-cp37-cp37m-macosx_10_9_x86_64.whl (943.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0rc1-cp36-cp36m-win_amd64.whl (900.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0rc1-cp36-cp36m-manylinux2014_x86_64.whl (958.9 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0rc1-cp36-cp36m-macosx_10_9_x86_64.whl (950.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0rc1.tar.gz
  • Upload date:
  • Size: 568.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 107feaec6b4e6acb101bfd68a47d07c93be6df0741543cd3580b30fe1b84a96b
MD5 a202036a0112991e40a9b6e1aefa9c33
BLAKE2b-256 167b6b13261e80349fef5b7b4dc6db3276e0650d6b869cb4e7644e220c755d0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 907.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5c774e2cb0b4cbf6b62cb693a6caa4ed93e1ce5fa8287b061da663a6992741bc
MD5 52c27a5c8420391db637809dac359654
BLAKE2b-256 a02c0f680c8e31e755394edc83a608cedd9f3df027a05d6b1bf6dd7184e83a3b

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc1-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc1-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 964.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c3bea11c92631ab85b7baa65866c13aac68f1b23f337e6687421db2d29364d9d
MD5 84f3d58f68732e241f9680c180a891a6
BLAKE2b-256 99a4b86f60d8daae53886a8a2b4e5a04c4916a1800523ac50f937055154fb3bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 947.2 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 568670ab8e251c71075760454931119e06fb2734cee3d295317c9dbbe0f13a68
MD5 7b7f0cf4d43ac0d41f588065276b5d74
BLAKE2b-256 96e68746401a9b5cff6f6c45b48a6caf916713aed505f233253d43b47315f24f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 900.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 abae9b5e386ca28a0877f1689fc8bf6f77cbab2eed804afd8e93737be0526de2
MD5 ca02324fd9d530888f04aa5584fac89e
BLAKE2b-256 f7f5e96d728c09246637d9e3f006b9d9268b1850552785e1bfb13008b6876a30

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc1-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc1-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 956.9 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24e2a0df85a38b503dddac99885d5e83a268d7e4ecc7cce639280ca03de4ea97
MD5 4ec650871b94694d6ac36c6617406ba6
BLAKE2b-256 a0fd294b798a19681e509aa4832da7b76d480e85f5353dc887f89bb4080a36f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 943.1 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 818d8b6dbcaf20ce999c73c42d948142f229c838fac0a2909dc7834544dc237f
MD5 6cb742a8ebc8fcd7eebfd7f8fb0a2efd
BLAKE2b-256 d1912495817bfb5461477d47e88ffddbf40d2ea7afb88a20f9f0ed95527a74bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 900.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 48813f652277ef00e2c33f4db5aff7d162cfc4e60b82563ecafbb994a3745db7
MD5 d854130dec3ddac92ff963486f01efdf
BLAKE2b-256 5be11d2b97350a3a421f4b2598f0733b20e5d407eb48b050c2171ec3d605f53b

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc1-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc1-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 958.9 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b10efc95de8213ee0e9ce7b467ba33f5101bfc6aced3d168e655591e63363092
MD5 6edeb8d38b55f469ddd0f111412e0534
BLAKE2b-256 41bc5c88e1cf2ec17a7479d37ecc564384df8bd3d922adeb77f621e4d10a749b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc1-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 950.7 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ddc00e73b744d6a606895b52e3c6051ae52a2018c9f5dcb4ee7e29d4fdd459a6
MD5 000db41051a7d51656da2c254f21fc94
BLAKE2b-256 5bf4f4157a683ea56c0ce791c306dd731f9c19fac373d0688f1b00e5e8194bab

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