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

Uploaded Source

Built Distributions

thinc-8.0.0a30-cp38-cp38-win_amd64.whl (926.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a30-cp38-cp38-manylinux2014_x86_64.whl (983.1 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a30-cp38-cp38-macosx_10_9_x86_64.whl (966.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a30-cp37-cp37m-win_amd64.whl (919.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a30-cp37-cp37m-manylinux2014_x86_64.whl (976.1 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a30-cp37-cp37m-macosx_10_9_x86_64.whl (962.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a30-cp36-cp36m-win_amd64.whl (919.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a30-cp36-cp36m-manylinux2014_x86_64.whl (978.4 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a30-cp36-cp36m-macosx_10_9_x86_64.whl (970.0 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a30.tar.gz
  • Upload date:
  • Size: 583.9 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.0a30.tar.gz
Algorithm Hash digest
SHA256 5c0ee9e7721f79b19e34dce1c9e9e3fa25a323bc0075b4e0b4115f03826d5a04
MD5 2966057e2d545bac5045ebdcb65a79d4
BLAKE2b-256 ddcb2d30f6d35f6b1807b100fc741255fd9a364409e69f3d66d221da2d4e0d59

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a30-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d854bb3c24b5ede3d7e9adc1b040e82fbe398f629194edc7a52d93eb73bfb55b
MD5 2025f5a412ce9c5b07e84d34e6079451
BLAKE2b-256 00469f1f8eb56eab9e3c329670dcb8efc5aa533e4e17667129a5d6b3371b3880

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 983.1 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.0a30-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d825e68f18058b2ef3f74bc321bfb2629ef726a24da06661642bebf6029f82f6
MD5 ab81f213e9dbe7a641c1febba3896055
BLAKE2b-256 4e4544130ecebfcf89fa858ca0b6dd9fb8127e84f7ccc2cd1d0bab58a2ba4670

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 966.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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a30-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 74ee78d5c5f8410e85d00596c60859130e69660f21b45ee1fb0762f7e5aacf6e
MD5 c336a1e6811651a47ea2c7dee081229e
BLAKE2b-256 0c131226162092ec8da4866c1bcd3ec53337997855206aec7726a6e96493195b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 919.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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a30-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 31182f52353a945ce044a89dfc13f9331403653af031e42adbfc5901303c9b84
MD5 4f07bda465c1d55044a419d8752c808a
BLAKE2b-256 4385839a83e3742619c9752f89811a4171e5100548169f4577cdf0827b1e4f5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 976.1 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.0a30-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8861fed05d6ed45ba9b64d96ca529b16bb04c6046c80757e261204fea8d931f2
MD5 702d9ba101228a15e050d1e8b7238aa5
BLAKE2b-256 6ef77e0a6dfe8fb8e9cd7f50d4dadb7aa5b03f264f1089b83ea540f42f53d86a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 962.6 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.0a30-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 097dee2208fcceb3e2a73ccdc6934f4c509d5a5cd9453f2d3d8fcf1aee4b8b4d
MD5 9267faaaa536e6a3806f99ff9ff2d113
BLAKE2b-256 c4e90ca9fe0a805500757180fbdda6662314286edabe2f36fefaca318e081aaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 919.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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a30-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 dc1a6e432dcf3dabfe28ca3efe3fe2d465ede927f036f36b1395879199b7f2ff
MD5 956600c1bc2c87df6e286461b77f4267
BLAKE2b-256 b8c833a5c5633420f87c544c4372e2526730bd5986a6861bb56ca5ce7eacad35

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 978.4 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.0a30-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16104f33d23bbdb4213d1cb88fea36236372737ca08bc4c862a83289a01fe772
MD5 c2d363978fba3858826dd1d983664887
BLAKE2b-256 0299ded6dbbe2fbb196d1a3de5b70b55cc62e50a7a0a3e59bfd0f8016e363c21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a30-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 970.0 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.0a30-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1d0a18b9e3992a2bc4f1bfac6e009e122058cb234e5a369224eec199c4d680bd
MD5 0505356ad27b711eb473e73567a32838
BLAKE2b-256 8cc8afdb921cdf22125140d0144eb8349d6712ccde0268127b8ecac2fddf293f

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