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 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

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.14.dev0.tar.gz (176.7 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.14.dev0-cp310-cp310-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.0.14.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (639.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.0.14.dev0-cp310-cp310-macosx_10_9_x86_64.whl (616.3 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-8.0.14.dev0-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.14.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (637.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.14.dev0-cp39-cp39-macosx_10_9_x86_64.whl (616.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.14.dev0-cp38-cp38-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.14.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (638.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.14.dev0-cp38-cp38-macosx_10_9_x86_64.whl (610.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.14.dev0-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.14.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.9 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

thinc-8.0.14.dev0-cp37-cp37m-macosx_10_9_x86_64.whl (603.2 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.14.dev0-cp36-cp36m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.14.dev0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (631.4 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

thinc-8.0.14.dev0-cp36-cp36m-macosx_10_9_x86_64.whl (604.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file thinc-8.0.14.dev0.tar.gz.

File metadata

  • Download URL: thinc-8.0.14.dev0.tar.gz
  • Upload date:
  • Size: 176.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0.tar.gz
Algorithm Hash digest
SHA256 3e683db79dbc164e9b0586e0e8f6408f39a8a9bba5346f955cb2830c74315b56
MD5 68999839447b233c17f020482afe5e55
BLAKE2b-256 8e29a4a284e0eb04c770c6944a71e451ad7c56d02d9e76eb7609606cbdfc204e

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 07e4195953ad2f6c93e1616bc3a01e1c37c2f07a41f10f8c4c492cfa46095a5e
MD5 132bab753663dd2af70aaf17e8b9d959
BLAKE2b-256 eae7a8c146d514b7f4cf7a963ea921aecbbfac41dc9fca8b21751c33fffe558e

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.14.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a24750f88471f293792f070dce79fe7ef7b2abf63da40ca6d397b665fabf6301
MD5 22aaee924540c680f81ffd0f3941b22d
BLAKE2b-256 d73bb250cd00e2e3f1d7b716adfba1a04291164fdb332a41374587e15a96785d

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 616.3 kB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2da75c0e6a19cd95e8fb288aeb29159b8f9ac1c110ae209999e126900d922871
MD5 948609d07fe092aa0d976783db8f8264
BLAKE2b-256 e39cac4413f3eba44e1b7bd6f7f9bc9bc5734b628baf676b9cb181d5ba4cd0cf

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 499ed4a9019f73b806d289fd108009aad9a13054c53afdaadf0e43cf8caf7d84
MD5 bc2c0aeb729590f885a8a13dcb9b959e
BLAKE2b-256 085423582d83008210eabf608bce04ca8f871f5b4394ca8e57c142766f4d03cd

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.14.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 48ec31ee51e93e59ff8135c456adbbe28f7b622a3924e19eb0e39cd3264b95b3
MD5 8dfde47f71c29cb50d24a66dfb9e0450
BLAKE2b-256 3f072210d1160ec7992fea82752042e641624aed42d0cd113d64129b866f6805

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 616.2 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bf4514d41238b9e45180c9ab78088795f22aafe2f7563cf890a4b4faf684eeaa
MD5 c1acc503e9637bd9c0e3b7003251e4d9
BLAKE2b-256 4dcf64776bac17478a5d37a905ab6e19999aa508598a74e15384927b05c91656

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 29c692c6cd57566c93b9b121254cb6681fdda1f327f0d82f670814b8e3321015
MD5 9a0547d648f73d520b4de338452798ef
BLAKE2b-256 073ec823221d891da3bf6187308c5268ebe76115ddf8e1f2697591a411e101f8

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.14.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5931a7aab25517aa08b1238ce84b77b430324009048e6dfdf2f43e866dbc5456
MD5 d1c5f49bede79a7687645e65b6c9ff2f
BLAKE2b-256 27006540a159959d1d79c694c2d2c785908d53896b329276fe647f8c9f45bddb

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 610.3 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 74cf5f9f3c8e92ea1b64330b7756ea1ce01dc83e542867b854e6bd161bae0110
MD5 5240afc55e125e55a433efc10abaf99a
BLAKE2b-256 30d253fa0c48009fbfd4ff7405d4614b155f58f14db0cf7835900f1a7a911dd7

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0c49a4679cccf55d4eb68a0f695d7be7683772bef10befeb333bfe658e39fedb
MD5 641bd3ce122bcff6634552fbb5b5bc15
BLAKE2b-256 64474eae4b3b1de9ebc334425af4c90ee01ee4ca0cf6cec8bb1cb4bff665e6ea

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.14.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f881862cf9ee943efa67fbec31aa8e55db8c5afc7cb31f2baab25edb24307374
MD5 6eba0a5876752423bd93527645c7658e
BLAKE2b-256 5a9846ede982cc58998572c5737f994d1ad8d915da1a8227b2667758b38798bc

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 603.2 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 de2e4e215e47ca1f40e0b5a50d39def7b20467ee6f147adef5cb35be33028865
MD5 5d45aeb0d132c72148f87690dd3345cb
BLAKE2b-256 1acc3cd06a32145c4aa83cfe499529b192f25674b2a323f4b18d3e9116049710

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-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.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7649293d4d55aab0c1fb414ccd7683d3d4fcd2d22501d7242ed3ca49249999cd
MD5 4e8cfebdf11c38e291a3bf9f2fc30380
BLAKE2b-256 86d4a7ecaf13f9a49cd8b5ed505e9a105f09d313a30d4af196658aa06b6a58b6

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.14.dev0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3192c862318f874f3a4037af31099d8b6a4ba2e461ea59dcf1339835861ee7d0
MD5 266ade1315227b52b0f6aef1521597a0
BLAKE2b-256 906e78856280eb2dbb439843b5ac8917b3a15357418bf021941313635e04df9d

See more details on using hashes here.

File details

Details for the file thinc-8.0.14.dev0-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.14.dev0-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 604.2 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.14.dev0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 74c4964f521b620ee7656c41937b5abb86b3207788acdaa317de0b717645b1ac
MD5 f81342bb84c243c57cd790f76739e52d
BLAKE2b-256 1112a80b704842387d2e2557c9a6b2afd7490115871af97874d2294532bb6ead

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