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

Uploaded Source

Built Distributions

thinc-8.0.0a27-cp38-cp38-win_amd64.whl (925.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a27-cp38-cp38-manylinux2014_x86_64.whl (981.6 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a27-cp38-cp38-macosx_10_9_x86_64.whl (965.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a27-cp37-cp37m-win_amd64.whl (917.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a27-cp37-cp37m-manylinux2014_x86_64.whl (974.6 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a27-cp37-cp37m-macosx_10_9_x86_64.whl (961.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a27-cp36-cp36m-win_amd64.whl (918.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a27-cp36-cp36m-manylinux2014_x86_64.whl (976.9 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a27-cp36-cp36m-macosx_10_9_x86_64.whl (968.5 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a27.tar.gz
  • Upload date:
  • Size: 582.5 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.0a27.tar.gz
Algorithm Hash digest
SHA256 8dd497cb5e00e1d5a6ab6bd1d498ca2fcd2c5667a27a918b06aa668451ae890c
MD5 fcd1149f099a33449dcca2ec14ba6bb1
BLAKE2b-256 a6e46bb6ffbdba173f0bb326e3ad3cee4e5b013a3e9e87270bb6bbf0bf4e072e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 925.3 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.0a27-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 33a65092a333849e67f481e70482d888bc71954a7324399428b6538a0f79f253
MD5 fd67f2a395c2880f943d9c1351243d9c
BLAKE2b-256 ae4b60b5e9a15ef9df81dbce669654a124f164fc1ceb2fad06a92e1a264310e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 981.6 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.0a27-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 15942d4be1a0d9533c195bd34b8f0b85a2a25ce2e6cd5e3b62c39af1a1129728
MD5 c51d8aaf7b40207d0cb91b8d4809847f
BLAKE2b-256 8e3ea5b8d7446fd4d6f05a5ef6ed447fc22e105b48817fa3a5912403c42deafd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 965.1 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.0a27-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 21aba19ccc1b13f6189758486650fbc90ff6c54127e1a9e9ab4f6c84cb83e932
MD5 7bdca92647674f698118ac1dc59f05d5
BLAKE2b-256 66e78624ba30730eb3091731960ce80aabe8f9c80131cdbb31ac7bb582ff134c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 917.9 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.0a27-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 e34346958b0477e030e38796b967cb7f9224bdb92c5f45c36dc74ad3e478cb10
MD5 9318b3b6bb9296a582e4a34fc12566b0
BLAKE2b-256 f650b0cbf04cd2fcc3725dcf9891a11a917b5646dba1cc077ab8f654e866f9b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 974.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.0a27-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3cde097b1271e8dcae934eda88601394c29e7d13805046863ee1bc9dd9aba19c
MD5 3313e59f74f0c01849166f60fe6a014a
BLAKE2b-256 40969e8bd2b66acbb20d8aa7f54f375b79150be637db229d22a5fa981d8ba0a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 961.1 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.0a27-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0e3603f43a257ef2b7212d3aabd008ff24150fbb519155b8589984a18b94c3a6
MD5 c08fd93e1012b5bf2b7551f2a35705a3
BLAKE2b-256 1b8568f168580228fa6a6809113edd10dba2bed475526b70de94941b95952600

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 918.1 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.0a27-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3d3d67522a08aef107cbc288c5a015bfa5453f09107b9c09ad0715c9f4dce282
MD5 aa12a46e12a3f4f0446940e5096c6222
BLAKE2b-256 caa8fda4dd4bc842d5542745b46eb26779f01435415abe35f65307f2d5ced8f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 976.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/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a27-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09b5ddd991fb1dc83c6f29ff9a047d75bdf10430dad886dd40e33084e9077d9b
MD5 5b814af50a038b2dc5d8ca2271f6ef8b
BLAKE2b-256 d19ee2eb5eb969a57dcac44da2326168bda369f437df77bbdf874eeacd8e852d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a27-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 968.5 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.0a27-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6fd7ae72081989fad6b7f553e95efbabff0b68979e0079beea2b4683d76c4a39
MD5 32c6aafbff61a8f17929f2820afb9dda
BLAKE2b-256 4a894f58a271ca25b6e30354c5c592b55507a71c733db275c7b0c6012fa06fde

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