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

Uploaded Source

Built Distributions

thinc-8.0.0a25-cp38-cp38-win_amd64.whl (924.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a25-cp38-cp38-manylinux1_x86_64.whl (942.9 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a25-cp38-cp38-macosx_10_9_x86_64.whl (964.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a25-cp37-cp37m-win_amd64.whl (917.1 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a25-cp37-cp37m-manylinux1_x86_64.whl (951.6 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a25-cp37-cp37m-macosx_10_9_x86_64.whl (960.4 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a25-cp36-cp36m-win_amd64.whl (917.3 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a25-cp36-cp36m-manylinux1_x86_64.whl (954.0 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a25-cp36-cp36m-macosx_10_9_x86_64.whl (967.8 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a25.tar.gz
  • Upload date:
  • Size: 581.6 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.0a25.tar.gz
Algorithm Hash digest
SHA256 a6840679cfe865f811045d7007730e6d68f4af6b01890ae331ca26c49682bb9b
MD5 a083976090f8b2eb5df8053594d38368
BLAKE2b-256 13a44d3d701eef268bf47be447b00b0866aa80e81438c5eb96960af69a138773

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 924.5 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.0a25-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 358b2bd5de60be4e690fb195a314b61e49a40cb7fce00aef433882495a8dd8fc
MD5 01c1b444336f0c19e8feda49ef07fa98
BLAKE2b-256 491a2e9134eb9892f86c01d8aa8c9fe73c6bd6f5f538117eab4070a54da7bae1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 942.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.0a25-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b42344760596b6d2434c62a4f6563f8ca92eda85d4b0ce261c96b68dad160800
MD5 ddcc43d180772730e7bab47ebf473ac1
BLAKE2b-256 2b10f486e5c8548f15a65f38ba70de03ceabdcdd7640e3ede3d95dc9e523e78d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 964.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.0a25-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7fc9a08078f5d3959ed3d674ea403fa935124c220529dc55f197ff6282ddce95
MD5 893886853530c6ed42f90438aace628a
BLAKE2b-256 dff9eb7971c4865fb7fa4bf8d7a4c5672a1b24eb8bf8283e1ff332efb6cba8cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 917.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.0a25-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 8c7f073d3d55a8ef7215458539a0b4e8cbb1cc98c1d4ed3d1cdd5b83b423f83b
MD5 ea0e6190512582bf4c89bc27893ba86c
BLAKE2b-256 cdfce1da0fd52a6402b116635c5dc8dc5162917c4abab2e0d2d780e288eedcaf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 951.6 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.0a25-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d2df61180b03ea7871b9134cf5ec6b870f94c6a41b2e45674bf8599bde3851b7
MD5 fb336d905e7330d0ff54e5d075a29290
BLAKE2b-256 69e3f0ab2de9cb6b2930df58be3da9d3a8e89662b43b07ed50073cd86e62b18d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 960.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.0a25-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8877d6624681f8a8037caa3d6572382928e00a996ac198941fcff4eabc03d982
MD5 bc5efaad404957336df4218c022ff89c
BLAKE2b-256 c5508476290bf22b7950a3e3afec2ac4bdf09257e0eba2f7096567cd90ff827a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 917.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.0a25-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e34a8358a4606ab542374a06daf278cb948e9d1c1a2e98dea620dc467c06d400
MD5 f4db1fc64d97eb77690046b66e78cf2b
BLAKE2b-256 c631376fb0c2cc49c8ea1afca83dbb60336610e531aa7d1c380e25adbcf2f56f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 954.0 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.0a25-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9112b22c3a84e37723fff24ca1a03c1a289ae315d49d2d7e946bdb3d6ea81f02
MD5 020a0d4b9869e7ac6e7c8ee3e3c14ea4
BLAKE2b-256 e5ae6ce17821a2240acb12ce5aa28c128f14e47a30f1dbcfc10c27fe5142818a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a25-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 967.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.0a25-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 92865a1f5115d8d96ce2b14dda0eafa676cc20e6cdef6aaa773e021c4a6fdb06
MD5 6fc12ad526c55a169b846eb0b97671c6
BLAKE2b-256 184358a59952996d45124d8e4de4314ac16e4f6e9c943c61f93c71f568974f29

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