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.

🔮 Version 8 out now! Read the release notes here.

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.0a0

⚠️ 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.
Philosophy 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 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.0a0.tar.gz (575.9 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a0-cp38-cp38-win_amd64.whl (941.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a0-cp38-cp38-manylinux1_x86_64.whl (971.1 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a0-cp38-cp38-macosx_10_9_x86_64.whl (983.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a0-cp37-cp37m-win_amd64.whl (934.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a0-cp37-cp37m-manylinux1_x86_64.whl (975.6 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a0-cp37-cp37m-macosx_10_9_x86_64.whl (977.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a0-cp36-cp36m-win_amd64.whl (935.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a0-cp36-cp36m-manylinux1_x86_64.whl (976.4 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a0-cp36-cp36m-macosx_10_9_x86_64.whl (985.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a0.tar.gz
  • Upload date:
  • Size: 575.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0.tar.gz
Algorithm Hash digest
SHA256 ff65e105f154dab0b3b690441f548b2293bb2b065b70161dadc336cd212347dc
MD5 3b8242a2df41e431a4bc6fb168be52f3
BLAKE2b-256 45832f6b69b9fc820f614cd8cbefc6d5096b02b12db4b6d5f577b15686eeefa2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 941.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 49a2288677d61097d3489290e2181a425d6a80948d321dffffdb9622124f7f38
MD5 de8181be6d18cfe3fce1572ee595f252
BLAKE2b-256 254c2e9bb48a14f7e1d4100181bee8eb49bda039b72389b8d39b308a1eca0930

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 971.1 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9ac1afa79f5780832cc430daf792502f09155598499716a1cb5df252c402603a
MD5 21f5828a3e9f5e3087eeb24a098c2ac6
BLAKE2b-256 d0db9972f6e249e3ef22ccfe07128bd32773a1193f4e958494432c98609ba97e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 983.6 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c9ffccb8c718ffe99353898b031c4eb99e2f825ec609600ebc84e6b8d9bdc89d
MD5 e1df65f1083dc9bc196c947c98180631
BLAKE2b-256 b87998a9a4e0681d24888ef80b0c467458c5c75a7a08eb11aae646944069c6f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 934.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 1b4437619b91c01fd76b9fc2e16cec2f0cba19333da5fef8ed29b55eb3acaa09
MD5 fee48fc65734461e460664195c261b61
BLAKE2b-256 6e3b213cd7a9391278d30b0ab9837cae422fe880c376bee5d5a7fef1cc4bc01d

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 975.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b741c086a61623f911e1710fff559c17d094f3942835665f85c424163a26225a
MD5 5d6fde2a3e24df2af605d93643086fcc
BLAKE2b-256 7bd51db325aabe723b3613e45b52756f2b8d75ccabb88949b4cffedf0b19a0c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 977.5 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 206a14b2a5e74546dd2f432780f4e3a2d8e515a554c34dffb2355db171d846da
MD5 4e49c4e992c67f7b84bc2b7bde9e3b6d
BLAKE2b-256 16a851994491184f77f919bbf298d220b8c7de7101bc74e40ee5563835750ca0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 935.1 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a11241616f0196717cd0684abdce658e326dd24c98cc76ddec2d517575318b9b
MD5 9529357617dc0913a2e62520e961f501
BLAKE2b-256 ac1816b2cfd119838737f789aa593937faf935d97c0cc353c9c5c21542ff1ed2

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 976.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1b6caa65c66db877f7d1aaa0cd039f64fb48a9567e94d785b74cf567690629f7
MD5 9c9a43746e6aaf99b9d1492d687c6a4f
BLAKE2b-256 07642630c151d99aaff22d6300a8682302343483002c3cbbc32ed8c5ff4e1f91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a0-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 985.2 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 66717b24350c5601918833f3a0cf4415e3c2792aa6c20883afe1b85794d31d54
MD5 ab42c7728212b387e91113b8eb1f2deb
BLAKE2b-256 ae7a3ec089a3b7089a8a80a15f3122c46ac4244b0de646121099997bf6ba040f

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