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

Uploaded Source

Built Distributions

thinc-8.0.0a35-cp38-cp38-win_amd64.whl (906.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a35-cp38-cp38-manylinux2014_x86_64.whl (963.2 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a35-cp38-cp38-macosx_10_9_x86_64.whl (946.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a35-cp37-cp37m-win_amd64.whl (899.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a35-cp37-cp37m-manylinux2014_x86_64.whl (955.8 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a35-cp37-cp37m-macosx_10_9_x86_64.whl (942.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a35-cp36-cp36m-win_amd64.whl (899.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a35-cp36-cp36m-manylinux2014_x86_64.whl (957.8 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a35-cp36-cp36m-macosx_10_9_x86_64.whl (949.6 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a35.tar.gz
  • Upload date:
  • Size: 566.3 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35.tar.gz
Algorithm Hash digest
SHA256 7cbd9aae339c6073763e7fb355fb56b77ece9ce38b119ecb3f173459f7ffae28
MD5 67af9605ac53de4fab822bcff02823e2
BLAKE2b-256 b5efdc29b274c2fbc827958f0bf4994d637c466e63f5b40d204542ee8a27d2ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 906.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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3a48ea8559d3ac6154cd5a1ee1ef857364177fb551f8116c3e8ac8908115a4fd
MD5 bd0d71934865b3c965f6020a2c88fa67
BLAKE2b-256 025022ca03ac196ba85bd10fea0a54ced798d7dc3b7d9b0d7a030e1a332f2ff7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 963.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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6b7aee0be24f423d817962290e43c999d5dfc998123fef4828f28011d5fea680
MD5 1a0b42dfc9b51ba119c06f718649a8ec
BLAKE2b-256 94670fa8717f95c4a5ade77ddea63c4eede9b4aebcd31085209fc13e40501727

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 946.1 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6dfb6f2e903d93d06b59a79a7ffcb8c9f30eacf952f7ceb9ddbbb7115785eb4e
MD5 9bb83668b849f29b673c51afe426f705
BLAKE2b-256 b92e273876d71363180c2589ffef0300730981a6553507e110a0e145d5587479

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 899.4 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 891edf63e92d19ad61706d6a63fd85068a331e9366db82cfb766aa184e74c761
MD5 fe5fedca980d0f4db1639a670d71b292
BLAKE2b-256 f46863e57215756d7be2e42a4b580360d291f0dea2644eef2e5b827f297e3f8e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 955.8 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8805682a56dcaa24ea56e6c8310e8fede35f59095ca0a35f45fe846fdda1442
MD5 5e383cdbf5c96bf3e59e80f5093b3d97
BLAKE2b-256 522ea891ce21ab5b23db40617c384c811ae9e2562745f83037b616f7616d80ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 942.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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8fb7b66a8640b1c371d394d7577f6d9f53cde895bd9391ba2ab56a5896053d25
MD5 fedd9038b2d87a47a19d927f109cd28e
BLAKE2b-256 f2dc1cafe7b1c284936408ca0efea1b722ce8a2b77cadfbef915445ea7219636

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 899.6 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 98f2ac74eed0303ad0f2f6094f01d8abd58beaeb86242ff08b2aceff675b9524
MD5 9c460c0ccc3ed8c0fdaeffa9e26a0cbd
BLAKE2b-256 8e0921b9194b4efd8a8533a828bc30cf67330d11d9caca7cd116415c6423b7c4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 957.8 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba50d1dfe6857a1c5612d87f55c832c1bf50c30e8da73396fff975d8eaad6fc8
MD5 5880b04c8e1e49a7723e7091f759e2e9
BLAKE2b-256 ed13d0dabdefd19eaa6fb804ba4d860f0bf289c67b2ebff55ce1cb262fb26372

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a35-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 949.6 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a35-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d45a5fdd8f3c4a1fb7b65f7dd941550e6e88a43a24bf20b9826b3255ceee6021
MD5 d202f05388f7d650c81a8c7011e9c5d1
BLAKE2b-256 f1186ca67166f192538eef2622ebde5bde00fa0be4b1639566582b2dcf7d4cbf

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