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.
  • 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>=v8.0.0a35"

⚠️ 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 and cupy.
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.0a40.tar.gz (567.9 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a40-cp38-cp38-win_amd64.whl (908.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a40-cp38-cp38-manylinux2014_x86_64.whl (964.8 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a40-cp38-cp38-macosx_10_9_x86_64.whl (947.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a40-cp37-cp37m-win_amd64.whl (901.0 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a40-cp37-cp37m-manylinux2014_x86_64.whl (957.4 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a40-cp37-cp37m-macosx_10_9_x86_64.whl (943.7 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a40-cp36-cp36m-win_amd64.whl (901.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a40-cp36-cp36m-manylinux2014_x86_64.whl (959.4 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a40-cp36-cp36m-macosx_10_9_x86_64.whl (951.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a40.tar.gz
Algorithm Hash digest
SHA256 e44f035c69ab4d08c201802dce178ce971ae221830a86f660485a024bca7c425
MD5 c083581a2b272c5b5bccc0f172bcc0e7
BLAKE2b-256 96fb43d8ddbe3d002ca31a36f0f1407c4f4913f0b0a3c86352f916864bb78b03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 908.2 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.0a40-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 02fa7e9360055e07feecd7e2415cb51fab0be03007d964a83217106b7c821472
MD5 9276867af2b3823e1ec2fcb6d6c9cebb
BLAKE2b-256 664564c3b2e9b08fcb7a4520e352c94eaa3f06a92262a2216d8f63bdc02407e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 964.8 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.0a40-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 069cdfa24fbcde39cc6283eb82c100b41c7299be8ad5ba4c83c5bfaf6de33cca
MD5 a1dddbd1acb58a4ecb8971f6168a19da
BLAKE2b-256 f370a629141d4655e29d79ad4bafbfc71a91d7c99d20644f78d0cc1ffe97f96f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 947.7 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.0a40-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7bf5edd357cbeb8c1f8bd6584f38cc69d47c810064391135d08cb93ffa224ab2
MD5 2ca88e76e4a9e034a4d6d87083d4d55b
BLAKE2b-256 997360266e65dbc023b30c6c9dc7c956d4d94055c33161b311b2f38d476d1cc6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 901.0 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.0a40-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 e951c432b31e7ac6875a24b9dafbfdc9fc971a22f9dd03671e95eaa882220a70
MD5 9b58555405782baa1d93da4316870984
BLAKE2b-256 6261958f1bbd879ae4272f9b587de64e6bd8e3aec933d647a096b1c5c949ac50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 957.4 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.0a40-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a5530ff80e5983b3808b966f43b388bada218169c2614afadd0e89466cc2832
MD5 89ab2f92ae128d9d4aa95356ef3f0f0e
BLAKE2b-256 e3211c1a778f2145b307f6d508cdc3601620958d12f2f0a7e5a545628f399879

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 943.7 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.0a40-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ab6045efc6d4334c35101c176b02c2a39abf19ce38af4632ecf8e3715bae073c
MD5 bc51d6825badada96aed6c1ce3c9cce9
BLAKE2b-256 dfc24832205d7ef20f0aac472d05475af7daf263ab2660ed95c65fc5a40c94c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 901.2 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.0a40-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c7ec5df13e2fae9f442cf29eae02ca19d1ed9c8b89d0e2a97d9cfe0bfe51fa97
MD5 70297aeb63e4dab9b36dfe31d78daa93
BLAKE2b-256 c26af5ec16144977e3d15da74cfd6cdc48a60e6e335549898112d5fbfadba5f9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a40-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a10647ac78b8d3384e8ca0af08e0d9a9cbf2914c7e4858da5aadd145c22132c
MD5 c140df56568b02ee5d57acdb6a8d6c21
BLAKE2b-256 4fae5639774ef17f797f09f940e19bc27ff444eed5a63f21a5742f3574e26ca2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a40-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 951.2 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.0a40-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2d206010acb0c84f1ce5048fbf7382c91c5d894c056f98ba20bd910f4fb3dd65
MD5 720025fb8e234037ee0eb7f100fd1454
BLAKE2b-256 85a8f8ae9cb15c837582c0c81815f9967ff0d55560b8df01c6c3b31d5fc735bb

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