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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.10 Windows x86-64

thinc-8.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (810.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev0-cp310-cp310-macosx_11_0_arm64.whl (693.8 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

thinc-8.1.0.dev0-cp310-cp310-macosx_10_9_x86_64.whl (761.7 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.1.0.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (820.2 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev0-cp39-cp39-macosx_11_0_arm64.whl (696.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

thinc-8.1.0.dev0-cp39-cp39-macosx_10_9_x86_64.whl (767.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

thinc-8.1.0.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (821.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.1.0.dev0-cp38-cp38-macosx_11_0_arm64.whl (687.6 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

thinc-8.1.0.dev0-cp38-cp38-macosx_10_9_x86_64.whl (755.8 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.1.0.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (809.4 kB view details)

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

thinc-8.1.0.dev0-cp37-cp37m-macosx_10_9_x86_64.whl (746.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

thinc-8.1.0.dev0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (806.9 kB view details)

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

thinc-8.1.0.dev0-cp36-cp36m-macosx_10_9_x86_64.whl (747.6 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for thinc-8.1.0.dev0.tar.gz
Algorithm Hash digest
SHA256 bc338d5d5aac24edad6152d4e5bb5a0cdb844181f044055b7b693fbc68ee6ed6
MD5 13c5e1ad54bed6f907afb2a3602c8e0f
BLAKE2b-256 13f6635860827480bca3053f7aa74bf0d43dbcdd372c3f0de2ad81621b215d54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5700d3cb8eb870892c66a86301e12a1de628d1f53d8bcb39b1cbee5cc106524d
MD5 005afaedeffe61d5ccd8f18c67f894ac
BLAKE2b-256 e21e25e81d4320a328db959ff10683e76a3cb13673a9bb8bfc6e4d4920be5e36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5980e151317a047a0b5f1bdfe5ca59ceb7a20c2ff9edd3785ee0755ae56c912f
MD5 ec5f9f7a2133a55043b846aab7870cec
BLAKE2b-256 f3de39927410f11af3ef753eb9f680706cc35fd42a5da73d423eafd87e624d45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ea9f330b74f9dd700f4c9209a092c86af0892956cca49fb71747b7dde8797ef
MD5 413ca3181bb396de03085c110ca1a6c2
BLAKE2b-256 0ac28d4cf47f9a2b3a02493ff118bfca88e495b4573d7fdcaf73846f25fbd914

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c128c361d7381bbb2eefb82594e06715ba31dc9bfdd99b8553482c5b640af18c
MD5 81f6149135f55882c82454cb932243a3
BLAKE2b-256 939f76592c336c31d1025bdf6b45c0c065f60550991b08c1d72c5b02c78095f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ae667fd39ac47840ba7ef6810f41fb5764040f6541b0ce9790f888679db20207
MD5 435ed288fa830e81223e01a1fae2798b
BLAKE2b-256 ea9e290b8bb9ed2fc4594eae1cb98de57df2d155616a8541bb25feb7b0a9889e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3b0da958cc218ae7912eae34ba44a2ac3ca2476c8b98ca381defe95be36bda5
MD5 95594bc40e797596f6df2f4d72142b36
BLAKE2b-256 b619ee887759e8dece08634569751fa4402eaa9d446043b58e72e4275cfe2577

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14dc923b54a2a625229ffbc74d925a156f9321c4f309a9ad9a9dd4dd870b9de4
MD5 a35bf62151d216d2232518763949595c
BLAKE2b-256 a5b63f08f86e49ae2f13846bac4e1e8db44e5cb30a199f32f93ac0c2e1425d43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2cd460cd9272418b77da7108caa07cf26459881346ff529482e377039f976a68
MD5 152a184493b65e082b2b6e493050da3b
BLAKE2b-256 603feca43b8fe62f1bf2520f5df2e8d2c1ef597674a5dee67412f4823b7fc017

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 46ced630f22a452062b12488ccd5e8560bc94501133aa35ea93f94cfdc44d296
MD5 7f96316359873db0db11b790eebd5d75
BLAKE2b-256 dad7cf65e30712d864cd0abf365c7f1de51e1fbeefbb43d8e6c6056b6a1851a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4355191db7671c97769322831eba7490f5c1a5bd7c67a0c0e6e4a34e71b302b
MD5 00673f041ea1fbcb2c8a1d5af9c2d7dd
BLAKE2b-256 5554d9343a56931a9cbf2fb3bf546483e5b1d2357bca2221abf7d44f0fcc307d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af30a457942be35414b2f45a6ceeb6fe155076a840f1104694bfb4d8bc9503e4
MD5 58a6553710f914c596d5f22d5a2448ad
BLAKE2b-256 aab4aa6bd0e48b389f31d1ad853b71b25ccb5350ce50ab11aac4d451211c80d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e69aff0f3f5c714154ae94913c4864673e7f3d4a943647408dd405b9468d5286
MD5 97bb27dca6aa02effcbeb24d8c9dae2b
BLAKE2b-256 cb049f21219feca06cfa9080e388ed03ea9953465fbc1b423341a99f9de7a34c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f1f4e864f0b1261fed714dc63fc086c3f2db4b2eb88306aec677ebe9385a5168
MD5 4f1ff34f2523c3e0bc0258a50ead91d5
BLAKE2b-256 2260bc3c5283f474e35e39489c47b1be44993977b8dbf359ffa32d1b4bdc38bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ebab4804e24023336bb2b29789b6779540f338c8e649ac2f0609e4b452531ec7
MD5 88c861e03bf3d4e46a360ccec00da030
BLAKE2b-256 46a4f1cc810163016fc324e6da0892a3af4aa1f54b1b4a3eeffbe173864db01a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 576a5e29537dc6579bd08d65f6b8e33bced06dfb5ba99da13c08a79bdc7fd07f
MD5 17c7c14ac494789ca9a621faca095d79
BLAKE2b-256 64ddd66e652442995ef3f51049b7bb3c153ae04f07360997f37a97c19948370f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 95e3bae45e8a108a2054c49c234a1f36a14434047e7f8b440a666e9bedbf60e5
MD5 c98fc986274ac98e4e5d3c1a76c9cf48
BLAKE2b-256 7e4ca39970b36b7da3b738305c365bf813db600213a4a74de4b5fdec0897c202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 345189c8c7e223152b065b1f3f8f11b44b4990a571e33bc54f2c2a564086a397
MD5 0572e1ba0aad0ecbfdc9f554c0053619
BLAKE2b-256 a88959115b344c509889e59e28e3d10b78d9a3d48f2dcf483a352bc9d1033416

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.1.0.dev0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c260140c6011c5b671df4cf3702e4e567beb0b44d594244cb53b8aadd49a701f
MD5 1df6313396179b0aaf653e355939e051
BLAKE2b-256 3bfb4b2038e0a79d4d6500454adc3f715b01e199fb97062ff2127f68853e9f25

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