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

Uploaded Source

Built Distributions

thinc-8.0.0a24-cp38-cp38-win_amd64.whl (924.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a24-cp38-cp38-manylinux1_x86_64.whl (942.3 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a24-cp38-cp38-macosx_10_9_x86_64.whl (963.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a24-cp37-cp37m-win_amd64.whl (916.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a24-cp37-cp37m-manylinux1_x86_64.whl (951.0 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a24-cp37-cp37m-macosx_10_9_x86_64.whl (959.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a24-cp36-cp36m-win_amd64.whl (916.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a24-cp36-cp36m-manylinux1_x86_64.whl (953.4 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a24-cp36-cp36m-macosx_10_9_x86_64.whl (967.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a24.tar.gz
  • Upload date:
  • Size: 581.1 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.0a24.tar.gz
Algorithm Hash digest
SHA256 abca19609fabd4976604a205d4f0a15383a7496c0d20916d02f2442253169c66
MD5 4b1b8b266b0aae35105ca5cf17c2d3e8
BLAKE2b-256 dd2167e37927d6807fc63f3ca5f4dfe92027af15aac8a983311e029b938b3853

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 924.0 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.0a24-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 eb93ab8702e1954eea399acd83607caad656e34b7d9e094973cd1d81bf08e322
MD5 b76f8b7b3b2cb3fe5aa062a6505a2498
BLAKE2b-256 37e2acffc1700cd3672193fa78df618dbe4afecedbc57f32ceb3561b190a737c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 942.3 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.0a24-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9a4d41292867b3fb681701148da02b2235c2da35c11ec92614bae92b27da25a8
MD5 0ff5296bd6e9246e84ea39a95589cd68
BLAKE2b-256 761393f1fc568aec8624021530fdefdb95233a89a69dc23de6a9d7e85e51617a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a24-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a19732596518c465dee113b181403312746cef38d3745f7452c447fbb9b0e4d2
MD5 e0872f484f63ac45e8becc3dedd8e1ae
BLAKE2b-256 1b95813931185b0bce5e932f6ed9a893d6b70fbf228da08e1df2588daace4397

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 916.5 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.0a24-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d3dcf2163afac663e83a1072e851ad0545cc7a23f993dc546dbeb4e017a245ce
MD5 483efd4fd475ee8701fd1a494946476b
BLAKE2b-256 167fdc3b54dfd75a0649b9329bd6d2f30d8904ff6ca053afd2bfe2bfae6d7264

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 951.0 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.0a24-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 88c4bed75f6cd47897559321872bd93a5a45c31db4de6a42f97da5085969695d
MD5 fa79b84a6e9fac6c380d1fe1ea5a9fd4
BLAKE2b-256 93a061b39d39aeb78516a691abec265097b70eac061e701ca8c0a8bdd926553f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 959.8 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.0a24-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dac98eae0c5e4082fb55062c720a74411f200f401150fa8de449f276048c2a81
MD5 2059d6d1fba7a88fb07cc7c3fc953585
BLAKE2b-256 72f504382fce7413f18451fa289c6d15d7331043840997713a6e6cb8840bd733

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 916.7 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.0a24-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 0a0694eb50967b9432a8952cce3f842b9c2c77726e480923de8650f7cc07ca44
MD5 df50a7fb4f21f1637d0cbaf107c069cf
BLAKE2b-256 3a2609b43d209c514f3f5974ae76d558625d93d8a702701f4d0332772f98ff79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 953.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.0a24-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0cb61cc0edc53b13ebecf40c4d4f45b05e3fc1a8de045b5b1303dfea14dc9bd8
MD5 8161fc0d3f7939d0e0d2c6e4de9cfac5
BLAKE2b-256 0266bfec6b2dd2a23c902e7b104f6b82a0c16fbcd38e4c9d8ab7b643a58c4787

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a24-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 967.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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a24-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0c0093b41a62350ac917f2d0e878c093b5c72c599985df66dc7c0fce595d4978
MD5 bea1705c8f1072672db8d75e0fe25c8b
BLAKE2b-256 97fc5db0a83caef35fa3c0134641a9068c3c11e9dbcd14b640f8b7f65dafd519

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