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

Uploaded Source

Built Distributions

thinc-8.0.0a12-cp38-cp38-win_amd64.whl (915.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a12-cp38-cp38-manylinux1_x86_64.whl (934.7 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a12-cp38-cp38-macosx_10_9_x86_64.whl (955.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a12-cp37-cp37m-win_amd64.whl (908.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a12-cp37-cp37m-manylinux1_x86_64.whl (942.7 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a12-cp37-cp37m-macosx_10_9_x86_64.whl (951.7 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a12-cp36-cp36m-win_amd64.whl (908.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a12-cp36-cp36m-manylinux1_x86_64.whl (944.9 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a12-cp36-cp36m-macosx_10_9_x86_64.whl (959.1 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a12.tar.gz
  • Upload date:
  • Size: 572.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12.tar.gz
Algorithm Hash digest
SHA256 830ff8a5257f0de65a0a8c87d664ba3ef8211ab0829eb730b8ce0166d972b4de
MD5 ec98811a96e346ee50a8948c4e89b938
BLAKE2b-256 cfc257f89f62c043f7dddca43a702803188ba66c74a38d0828f421edb393f862

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 915.9 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6038d970eef750f7731e053703316f478f9c0ff37e94e7d17ee28211851fd1a0
MD5 c46c67d454c15810e2e88627e7a20c1b
BLAKE2b-256 da97e216264b7caf520e10edd089e10113070dd1c23af0fcc7c8c24447637fc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 934.7 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c45fe4b6201f72495a12136bca7c5d28bfff1cf6e32f390c79a6e948a94524f6
MD5 15be5f44bd4af098f419afed5939f5c5
BLAKE2b-256 85f1a4ff4246319b9c9741c3b6746ce63e51587d04ffbeea2be9248b78fec39f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 955.6 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 20271e2c95259329da53ff30a21c9ae1333722c57f4cb7f26727fca73a9a81d8
MD5 467b38be0ecc6c5b73fefcd121c0d2a6
BLAKE2b-256 8b6097fa3abf72ed884ed7f1bc0514fadbe63a8ffe258ff844834d7773474d95

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 908.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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c38d5baccd393ecc0c0d2dab63caf2fd824106436858fe968648422cbd4b857f
MD5 93edf5391742b06d3917e841bd777652
BLAKE2b-256 853c7c106df27f39dcd7635c9e86d01e706cc8ffb04e82c33103f9a14184bc89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 942.7 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 be17239230809f2253c1a50fbffd2a435335f7cf261896ec84b591ef19dbe2c5
MD5 d83e4ff0c4e8ad3dfd217c206b8e5c4b
BLAKE2b-256 995fd27e2f20d0441f9b389307649abab0a3f162983da9627e0bbf69612cbcb2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 951.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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 18ba9a88f06e69303c8251268eb1019e204e9cb431184821929df200fbd90203
MD5 839a10e28637a3ce02b3d42089a9f79a
BLAKE2b-256 566eea57d27db1041e8d52f46db5ebb078ef68b2f6f7103052804cc5ae372178

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 908.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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 0f0873b9547d0b9b137f92732048ed373cf7953446fb2b4d400a3675bd4caafc
MD5 186bb0c0ad27198e441f59eb49c3bbbf
BLAKE2b-256 24826a2a3b9f8f842fe97e23d211e808b042a22dd22e757fd176b9f30cf41960

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 944.9 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5ed6d86ace4946ab0810200c9aff4cddc7592e1aecc5e2c56bf4bde11adba320
MD5 8ccf9cc194ba51113295e583da4a577b
BLAKE2b-256 52a399b1a3457b10d401540b0f95bddbb52e8386b3df8c89e27c193bef1cc1ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a12-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 959.1 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a12-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 46f2db04c8c370eba4a117c1a4d33e5027e1d349210d0d6649842e006db42069
MD5 809a2317583e5b3c1b847047762691d1
BLAKE2b-256 023474968eb6a0e6a8e0a83c5aa246adcc33b784f236b25757735b21899b2c12

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