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

Uploaded Source

Built Distributions

thinc-8.0.0rc5-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.0rc5-cp39-cp39-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9

thinc-8.0.0rc5-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.0rc5-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0rc5-cp38-cp38-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8

thinc-8.0.0rc5-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0rc5-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0rc5-cp37-cp37m-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7m

thinc-8.0.0rc5-cp37-cp37m-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0rc5-cp36-cp36m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0rc5-cp36-cp36m-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6m

thinc-8.0.0rc5-cp36-cp36m-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5.tar.gz
  • Upload date:
  • Size: 618.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5.tar.gz
Algorithm Hash digest
SHA256 1e4ffbd3462541a8c880089018b8daf2adcc89aa514634b0a3a0635fd2279944
MD5 8c3a9522ce559127ed107b4cefb7bc78
BLAKE2b-256 ad48260765e7b64e90c6b2ccb230c786a283dd2d9eb3233c2b8372f76f76d8e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1acda75642aead409f297249600d17040724b9d1dc68009ef1f631d03807aeb8
MD5 819d1145922a2b5e2a133817fbd923b5
BLAKE2b-256 ccfe4f839ee0e732bc0d33191fa1952a1753cbe35aa0373f4819dbb304208d33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4c65f0f5bedc1c5e8eb1a5fe1e6c5cfae721baa10cc9e574ab1acbc6b7bd020
MD5 61445a065d3ddcebfb6ccce0103005ed
BLAKE2b-256 02c78f997d55056e9b0f3167a79e4249dcac51653fed138cc14ff0873cccd0f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b8c69aa1d66f4aafd2fa7721757ae6b62784190a4a786940d1e0e5bd58298a98
MD5 b43161314cb720f4234051af2cb4b77b
BLAKE2b-256 68e7f0b900657681a69dc5c10a43d9851eac6e672f10b4485c0e30b8b3f64831

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6fe671523fb7c04b06904064618f673915f889ec27ce38800ec112ead5a5a25b
MD5 b190f8eee460888319052a850104b618
BLAKE2b-256 055cf3d2553e46b728ef268618c37e491270fb696b44f368eecb9fa8ba6f0af3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b9784ddfe1062b42c081fec7a8bcbf1f08604d017d4f79c0bd673af61932845
MD5 d56d28fb2c981f7eea38e212d1b9ed53
BLAKE2b-256 61efb8fb058b897e0720da590b6af187e9d6f5453f0bc3fe097600dff818662f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e2023039bf361e1ae20c7683314ad85e34bfe11a47ebffe011386d96a6726c8d
MD5 b63881a3336606de26ffeb659e86ef64
BLAKE2b-256 92cbf9bff5413abc0c260319f87f9cb66971e0a4e39e6d62e5aba690ab47602f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 fad14d0d6962528cb850e1a5948d7cab516ff2534bc120863864a5dd94317cab
MD5 c328a8217cd1cf74214359db2a3796f5
BLAKE2b-256 96d5a06c7ed14be0d47a6257afbbe9a204b0311c99b664d8c33a686755a22a06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 96b3fe07ca513eed4ead126bb2d9428c113229c06ed52ac11fcd76780f2324e2
MD5 655bfe9891d77467b4c5930314b718af
BLAKE2b-256 ce397baa535d75118ba2293c096ed0edc525234f184ad030bb89224605eb0f6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 be4b018c267dfb6cfa0a2eb976526c3a8f5e738fed4b65267320d8590bfb19b4
MD5 f4135d7f92b4b5f500f91cdcb804bb59
BLAKE2b-256 3121ca8c8e2bfcfa256b880cae8210d677ef3fdd22aad0ccd4f3c31a581b641a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1bb5152d3cc77f65d906e59f5903b27ff8ad3a6f431c1e0181d90bfb692e51aa
MD5 2108c3b2fa5749df72e8af0790101501
BLAKE2b-256 5bb0ba1453a0e953a89f84ef9cd39702e82502a88cc5380d1b2372868d910c71

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73a52806da1b797aa46c94b6d64c9ff9b140dc83ee31bc6159b6abb0731a2ab4
MD5 d51664479aef52b6e17b68161814e7a8
BLAKE2b-256 8a5666b3c9741c9eaea1c94d0c84d8a13c17008f718d221a45646870477650c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc5-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c02450e1bcf2b1b4ea8665ca9add7e1b57dba7ac6e777f8cdb9ef2083f130eb8
MD5 d8e3aaaf107bc80e084541496938725a
BLAKE2b-256 2a9a67afd858fd905cfc06f2a4c09e705fd960f4849f5698a670de88a7bda2c8

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