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

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

Documentation Description
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.1.0.dev1.tar.gz (195.9 kB view details)

Uploaded Source

Built Distributions

thinc-8.1.0.dev1-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.1.0.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (810.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev1-cp310-cp310-macosx_11_0_arm64.whl (694.2 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

thinc-8.1.0.dev1-cp310-cp310-macosx_10_9_x86_64.whl (762.1 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-8.1.0.dev1-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.1.0.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (820.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev1-cp39-cp39-macosx_11_0_arm64.whl (697.1 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

thinc-8.1.0.dev1-cp39-cp39-macosx_10_9_x86_64.whl (768.1 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.1.0.dev1-cp38-cp38-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.1.0.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (821.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev1-cp38-cp38-macosx_11_0_arm64.whl (688.0 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

thinc-8.1.0.dev1-cp38-cp38-macosx_10_9_x86_64.whl (756.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.1.0.dev1-cp37-cp37m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.1.0.dev1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (809.8 kB view details)

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

thinc-8.1.0.dev1-cp37-cp37m-macosx_10_9_x86_64.whl (746.9 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.1.0.dev1-cp36-cp36m-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.1.0.dev1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (807.3 kB view details)

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

thinc-8.1.0.dev1-cp36-cp36m-macosx_10_9_x86_64.whl (748.0 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file thinc-8.1.0.dev1.tar.gz.

File metadata

  • Download URL: thinc-8.1.0.dev1.tar.gz
  • Upload date:
  • Size: 195.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.9

File hashes

Hashes for thinc-8.1.0.dev1.tar.gz
Algorithm Hash digest
SHA256 3aa0f2036172124f6a510e44b2e9b0514cbd3371ab3b70be0cadd4de9a6770d8
MD5 6bd2945f2970c0191547e44461a159cc
BLAKE2b-256 de274369fcafc2ab9f54e13b3bdd72b7ecbaf76915afd0feedab09e3c4b4f456

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4aba814d6c87195fdd8d5d5c2e0968d3f40304ae741d6051831d0247d81df6e7
MD5 d75e114bc9035d6a208424514edfac1c
BLAKE2b-256 9d8a78b6c956763cec9df34b2a6d4a0b0183fa55055f724474f7c8ccf47605c8

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 99eb59f62aee441d2c49c25267cad324381638c312074177ec60ab90e43e7cc7
MD5 648f2bdcd38c8e15246b8e1196e826ac
BLAKE2b-256 d8469cc606513da4b013e2a31f80d52292666dc3fac7f063d1f13569e0fd1886

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d20ef585d2795c13e390b839a73e099d9994dedda92569f0d6a9ad8873e14833
MD5 e18b8ec57d6a5423a3b0ce22b14386b8
BLAKE2b-256 58251a684fa7bbd8c2edc5639d83535cae3f996d041a99b1dffc6d0a5e5a019f

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9756d768bf3df0cf48710287ad1a085fd592622574fcad33367e82c27fb598f1
MD5 4f255f584262b404fe65794857b8a89b
BLAKE2b-256 e8a6b0bb25fd3debe6452b94ef8a22bbf9937e30c7764c96252831df6f08dee0

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ab4e5bcfdef5fa12bc5f5e83317a695a83dacf349b9f950ee68e6936b1a5f2d6
MD5 ddcbdb0c2e1a22248872151f81f3cfdb
BLAKE2b-256 48293bda443aa066e72e00215382c0d190b02b55a26c92b542cec070d681db70

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4bf781d2ff0bb6a17416cc6a53855696c1803989c82386b9d12d920010cc56c8
MD5 36d6441c849cc4deeea3ebf1dc60a243
BLAKE2b-256 9a9c5648dec745237164caee064d738b97380fcf3b6b81937c81e6cf31893ca3

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d024859dcccb9bdb622811b1851ef53055452418753f1749670d6308d5cfb90f
MD5 919c74f6a041b511b818baaa8d7e750a
BLAKE2b-256 2302fddcb4bebf1ebeefe0a2be285c20f04094814e35e388530e85af8101113b

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c0e6c56054492f73b12ff5bb65ec0c78734183d2dbac5623993059a4acab3e90
MD5 a60babf511847a2af0d8c660161582ac
BLAKE2b-256 2c203c3a4c43707bf608d3f99b184f2f209e615b2c9df90f23e915581f95ca1d

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9e7b259a330f91c47a34d1dcd9bc59e17ef70e3657e337bc045f76c75bd4e840
MD5 0848ee14720e715366a9689115bd60ce
BLAKE2b-256 92022a45472ef5fa971791c978ac0f99bb145ee934b9af1e3952b1d417cdb362

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62f8c226257baabc6b5bd04546522b01204c01744b2014fac0057268e7a43f3b
MD5 79ca04ad2ae4cb68634c56ecf79a7e38
BLAKE2b-256 d2566dd760f1c2204dcdce916fdf731aa0b5665efc9fe4722fd7433f3cc3f58e

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d6d01ebb35acec1eb4d8187525a4d1e801a1426fc0a8add6925bd12ddbc42794
MD5 9a22a5b0cbfccf5c6ab053aa80ea13c3
BLAKE2b-256 da4653c6e365e84ce564103dc9f5a25ca32d58eb8d91fa3c5366faa9ff9c1d08

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3c36629eefd2dad207837bdc669b92d61cc084f19cfc1849327bef88c32d38f8
MD5 32975ba0ef39b050aae6e5dce296924e
BLAKE2b-256 b71d23d0e1b8053684da96420ca5c3321ff176c89c4df74e6304b969819c9899

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ec2174e3a1ed7164ccaade983167cb9175b5ccd4dc4b0bbc0c90d318af35e6a7
MD5 42e1596116d6bac90c22c9c956815b5a
BLAKE2b-256 bfb68dbfa78042a3c357fe811e8a0aba003b413f6862554f3a2fb78e8006237f

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5dee3a3f69b9e87923663a0195eb099009d0b86b3256526b391dcdd14c1c424e
MD5 eb32c1921e158a0fb1367e8b61b876f6
BLAKE2b-256 5e512c021021060f8e6c09530d894d8d64dd958823a4f1700a4c985c1f55b340

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f6ff3480abfdb5064dcee86ebcc645ded17aee2b2e840486ac07a1da9e8ddc8a
MD5 43f3ef45f259cea7bb74de071245c04c
BLAKE2b-256 ab8358103251b57c8fd76305f2018249336a3e492d1a56f3104428728da2af78

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a2c4f16dc34a1eb46a41a2b1fb328905c3b6aaa7864f8163b296f6b5d664eead
MD5 404b05fcb85b79cb053399ae4fbcb3c8
BLAKE2b-256 1ae9bf6048994a2ad64a092de75f16609f1ca7f816684c3b463f3cc17d8271b6

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dbf6f713388e1b55fd57281db5fe5ebb0e43214852f6538228d880b403c13157
MD5 3899c240a2023f13e3465b5dc032c865
BLAKE2b-256 8a9e2291f198fd97bac5c11f5542310b06e8578e41bdf43726f8b0b145013826

See more details on using hashes here.

File details

Details for the file thinc-8.1.0.dev1-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.1.0.dev1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f3b996d7b18278175a9583553cc0704405d904a4a58ab8615ba412ae8d239d60
MD5 4f5998167fa6cafd261bd70e99045997
BLAKE2b-256 fb8835232bae82aac69c2033b4203059e12afa5bf02d6d6688dfaf97dc28c1f2

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