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. Before you install Thinc and its dependencies, make sure that your pip, setuptools and wheel are up to date. For the most recent releases, pip 19.3 or newer is recommended.

pip install -U pip setuptools wheel
pip install thinc --pre

⚠️ 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.

⚠️ If you have installed PyTorch and you are using Python 3.7+, uninstall the package dataclasses with pip uninstall dataclasses, since it may have been installed by PyTorch and is incompatible with Python 3.7+.

📓 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
pip install -U pip setuptools wheel
pip install -r requirements.txt
pip install --no-build-isolation .

Alternatively, install in editable mode:

pip install -r requirements.txt
pip install --no-build-isolation --editable .

Or by setting PYTHONPATH:

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

Uploaded Source

Built Distributions

thinc-8.0.0rc3-cp39-cp39-win_amd64.whl (910.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.0rc3-cp39-cp39-manylinux2014_x86_64.whl (969.9 kB view details)

Uploaded CPython 3.9

thinc-8.0.0rc3-cp39-cp39-macosx_10_9_x86_64.whl (948.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.0rc3-cp38-cp38-win_amd64.whl (931.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0rc3-cp38-cp38-manylinux2014_x86_64.whl (988.2 kB view details)

Uploaded CPython 3.8

thinc-8.0.0rc3-cp38-cp38-macosx_10_9_x86_64.whl (962.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0rc3-cp37-cp37m-win_amd64.whl (923.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0rc3-cp37-cp37m-manylinux2014_x86_64.whl (981.5 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0rc3-cp37-cp37m-macosx_10_9_x86_64.whl (959.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0rc3-cp36-cp36m-win_amd64.whl (924.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0rc3-cp36-cp36m-manylinux2014_x86_64.whl (984.1 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0rc3-cp36-cp36m-macosx_10_9_x86_64.whl (965.8 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3.tar.gz
  • Upload date:
  • Size: 571.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3.tar.gz
Algorithm Hash digest
SHA256 3ab8141723553ad6022dc3917b90c658fe9f0fa38e01b9005102b5363b76e736
MD5 6c7a55c5211b4bf5fecac0888f4e8a27
BLAKE2b-256 eae5769df3607c0aabc50a1568abec9735e14f65cc71fb3ae7876460df08f700

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0rc3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 910.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5bdb630b8ddd05a3cc0c03f0dc4c20d0cbb04943b68f19ecdbb0b764a27c30e4
MD5 dbb5a460446c5f1ee64e0cc4b09d1d9f
BLAKE2b-256 8617cde095258539423fbed3858ef5019aa0be116fc6cfa6da06d5fa062f8b93

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc3-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc3-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 969.9 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 acd12a2b5b22c8acb8106e846323fd63829617129522c86f91181df47dcfea0d
MD5 b62e846b458b79133dbff4d1202a18b4
BLAKE2b-256 852086133988910d9956b539dd3662d4eaeef12589d830f11c7fdced60c07a89

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc3-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc3-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 948.5 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ec8f4d4187eec6ceea7013a3a9fc3c005ff2d2961de671dc5ffcf4bc6c46da02
MD5 4b190fb5b7b5524854b4313f81cf0af2
BLAKE2b-256 c7cf7cb2ddeef14ff9762cec8f58460c0569b221403a2b88d82072b8b7f1399e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 931.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 57f089b287991f3af052557da3e2524e05867ea63f0b0a274b9dde973dc63740
MD5 a08ce9113245fbe531cc1566c4ac8e72
BLAKE2b-256 5e61fcbffd0ce55fd3025e673cb6d8f6659acbafbd9fcd676ea0f85b4aef5877

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 988.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b49bbc3d5fdbf175741c7a25dd9e72988976ff303d49e3100418980549a3f10
MD5 87d7935e34817a752adb1949ac250438
BLAKE2b-256 cdde5985af190de324172a746048bc5b6ed2a9c62bbcb6958e0c600b0605028b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 962.9 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 df2bacd4862356cb3e9b8e52191c174d71f6f81345e23038a238c53278c4f9a3
MD5 443af0a06b6ffc438c2385d19089e4d2
BLAKE2b-256 810388661104e2b5ee0430fa4614829970e7295cdaf7bcf15283bd01780c931a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 923.8 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 22673a33a5d2f16fc265b57ece7941428975fad26ade2aa62eb7b07cf270f4dd
MD5 ab5f75d49dc1dd96df814b6c44e7b051
BLAKE2b-256 eab1f18798b138daf144346d2e12d9645b342a0d0eb48a5dfc5f152780be076e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 981.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 faba9b012ba8199e92184bd7f8f0723374e959fdc1a534dec3776185badee3ab
MD5 42d65305c303e999590e6ed8b4366279
BLAKE2b-256 485e9f561cab900cb8b365a56200b1f99c0209c9138f7b1cba9b2a30f83f9211

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 959.1 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e8f9aeaab0752897ee49c1b28da224c65d517aff8442ebf0ff8f535aa5f48aea
MD5 cd627b5a512144f46e71699258a383da
BLAKE2b-256 26350abf66bca5066b197d35e472e44a1c5f3662f9d8fe6b509d5e61d6990968

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 924.1 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 4f65d529d1dc718bc80af27cd1015d083b094486f14df9dbcf1244b837c88c0f
MD5 bc5a728d130f542106e4b0a33e39607e
BLAKE2b-256 b368beb4c4b807b4982fc2515b9b03dcf6c108402e3b4c199e2a4edeb935f145

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 984.1 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2b314fc25d83696d01f8aa904d0942e05add04fd6e068e796217845002728b6
MD5 37a3283938ba8ef0ca9358b6608c1e4c
BLAKE2b-256 854d2e636d9dec34101299f1545d1d3a39f2aec7dfc9af645079c6836ff9278c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc3-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 965.8 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5acb5007ec0057a17bda74560ea9622b5681032371bf3c679f51dd9c3fd09d93
MD5 60699f1e8d891887f075a9fca3276d06
BLAKE2b-256 3d709bac8a8580eadff3e9e9966b5ba87efec2f90f4c99754255e309966eeaed

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