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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

thinc-8.0.0rc0-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.0rc0-cp37-cp37m-win_amd64.whl (900.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

thinc-8.0.0rc0-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.0rc0-cp36-cp36m-win_amd64.whl (900.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

thinc-8.0.0rc0-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.0rc0.tar.gz.

File metadata

  • Download URL: thinc-8.0.0rc0.tar.gz
  • Upload date:
  • Size: 568.0 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0.tar.gz
Algorithm Hash digest
SHA256 d8ff2cf9d38358d583e7e989eccfc6f13d3b2600ee388af99fef0ffe623dfe6b
MD5 45fc379c1936a58b4c55306143f54847
BLAKE2b-256 1dadfbda77809b2fe44614cc8b90ac67b8a8d183b8448d5ebdbd4fb0c367839c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4a9f5fa9cb69a12228802be827676c1a88730262b40ecab40256c6f3f14e1faa
MD5 1e8cf10e3445a5ac4c52c1ae12a017d5
BLAKE2b-256 ec38fbde99e1124dbd43af077773a013367ee622ef1704e2f897568b75b51dc3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dde56919702317d295972e869dff8491ad2c43e7b420d5196a0d8339cb24c666
MD5 9ec143e60edf34183f43109cf0239024
BLAKE2b-256 99d78455177a68fe133545e894784cd2382ccada4986fc5ae3657cb382ec1a9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2c07f9ee29338ffd7217eb306c2ef15f2c5926555a741b74844bc9344da0999e
MD5 a059ea617dd3da544ae49bb5205c6e3d
BLAKE2b-256 377d32238060d0505437298f51921a927db77cb23fc092281fb3cd7e2a443f5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 20aca6db7657838fc10a412d3d7df689cb91d8a7d97adfe5adc41ca123f8e728
MD5 3ac20f17b4c5dc25e69fa27b35b90265
BLAKE2b-256 36d48e509294a13714dd56ec065d9ec3171518eb9c6a4883644c473d29b9e1f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee24731b8019cb1a7d7db68319abd89b4ca69c449463fe4e4621571301661b05
MD5 1c8fc9671983c257cfd55e07cb77bfde
BLAKE2b-256 acde47d2fc28b789652eaa46e6c92e91ffe41902d0c360d3cd10c2fb9aa063bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f7aec748653f099da2ed3ff6d0ce90407063a5e92efb5a31226dcee6b47993b6
MD5 9667907b4e8852a5c63906d173b71395
BLAKE2b-256 ba06d5a1e2659733433a619341a0772ce70822a55ee74cad100e9da7d6003b2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 6efb380ad1d27f0b0ed2d7b27f4c31d3aad26f085abf1c9e88f618e79bc735f5
MD5 edcaad430be15ae8f50223befbefd0cb
BLAKE2b-256 eca96d26e354edac648e0a0ba149704fb91770726dcea12637f44e7f4e06e1b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44a860ee122a8a15410387be51ea433f40cab4d8ae8bec936bca2a123e92661f
MD5 250858ec1bade9bf387d119f0f4039c2
BLAKE2b-256 d79084a07d4e27b8429923c431ca6eba428b8ddd207dde75c210c222ce673e0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc0-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.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 714d8d3271d81eb436dc25fe5ae894e9621734306ce08411d77cf8c12820f65d
MD5 b203a1ee49446cc1ff27a2b7aff32a20
BLAKE2b-256 6a6f49d08eb195f2928b4a12a24eabe4869dbb3f8d9c1b746d122e2032a72408

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