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

Uploaded Source

Built Distributions

thinc-8.0.0a28-cp38-cp38-win_amd64.whl (925.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a28-cp38-cp38-manylinux2014_x86_64.whl (981.9 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a28-cp38-cp38-macosx_10_9_x86_64.whl (965.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a28-cp37-cp37m-win_amd64.whl (918.1 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a28-cp37-cp37m-manylinux2014_x86_64.whl (974.9 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a28-cp37-cp37m-macosx_10_9_x86_64.whl (961.4 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a28-cp36-cp36m-win_amd64.whl (918.3 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a28-cp36-cp36m-manylinux2014_x86_64.whl (977.2 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a28-cp36-cp36m-macosx_10_9_x86_64.whl (968.8 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a28.tar.gz
  • Upload date:
  • Size: 582.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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28.tar.gz
Algorithm Hash digest
SHA256 1117d4fed2dc266f97cb2fe4c505474fe698aa440a0d61ee4e1d67fa2ef33307
MD5 4dc4c0b2fed28892ec1f2c3f0d74956a
BLAKE2b-256 78328ca43992cbd9675cef2e644051410c8ab439ceeb1e671838d9d60084988e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 925.6 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a80bb2049286775f03f3f103baf341fb153d91d09d584b8043ce49fbf853639d
MD5 fc1ee85ad25473db1137573dfeefcf41
BLAKE2b-256 372dfefbecaadc2e290faa08a0767304d220ffbc6bf78b9e9b35e4739d3fb5a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 981.9 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2bd1e7e2d01bb359051b9d36eb52ef92412148442a8416ca194427b2a9d13d25
MD5 11028021ce62e8f057cf0e0969ff3256
BLAKE2b-256 98d693d9e343f6c590e040f317e837d0eb5b051ea8d23d9c8539db1288958122

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 965.3 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f3d1026c4e289e23376fb77a4a3ece9fbd5bbefb980cae0c702301c85e9220f4
MD5 fd3b69432d7515e67ede22737f4761a6
BLAKE2b-256 64e3f73b14995a2e3181a7b33544721859f4330b31ecd589ba88a6122e45fac0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 918.1 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f9cf7ee2632a653029e988a83001cc33cf5b9d60d6673531dd82e28267749b56
MD5 b853c02e15af6bc468ceef481e9d2134
BLAKE2b-256 3853a63b2924c60c2bac82868057683c0914562e28142055c16901a35b7b3af4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 974.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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ff05b2b5ccf6f842ec3c4ab306c7e490ffb05b941dff0f174f2870f50ce56d5
MD5 0f436da7df14f726071a00332c1dcd07
BLAKE2b-256 947d78f3ef779b78bd57ba8f45e93af5a6be175bc8bdd9b848df9595ea8ba1d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 961.4 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bcd338e56eea460534a9e650a156b3641bf830d859387f34f064d54069c7c3a8
MD5 1c5a5dce21f9cea87cd7578385588f20
BLAKE2b-256 425575bdbca73118292642f2c47448d7d05ffb08d901df41830d44759f785fd3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 918.3 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 bb54ab7284fecb1cd6b5ba048f52b0eb34c17d081cb1d70f272a9a32942b8345
MD5 4570bbd0e2189fbe86b2861ecd1bb420
BLAKE2b-256 99b8b81312f13bbeed9d780a9644a123a4d406fba832e2944d10ed3936798890

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 977.2 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 029a127ec1b72e9f2dbe52a634e69f32e483ae0ac1129452e29f8c17c546cb6c
MD5 cec3f3dc0052d140446574f49d31a6c2
BLAKE2b-256 c0de536601b1df030f098a631ff7cf2b48816e65fa2eeb0b06522344bf92a21f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a28-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 968.8 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.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a28-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ef13c8b4974548baf824ca482bb0b3cdee9238049a7015a1986f90265d4c8db7
MD5 d56f72bd4624782b93d5e385af0d9eba
BLAKE2b-256 716beb99242d5cda59aecc82441ff16752c4b890d67929722e238515b09fe3b1

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