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, including JAX support (experimental).
  • 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.

pip install thinc==8.0.0a1

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

📓 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, cupy and jax.
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
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.0a20.tar.gz (575.7 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a20-cp38-cp38-win_amd64.whl (918.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a20-cp38-cp38-manylinux1_x86_64.whl (937.1 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a20-cp38-cp38-macosx_10_9_x86_64.whl (958.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a20-cp37-cp37m-win_amd64.whl (911.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a20-cp37-cp37m-manylinux1_x86_64.whl (945.8 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a20-cp37-cp37m-macosx_10_9_x86_64.whl (954.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a20-cp36-cp36m-win_amd64.whl (911.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a20-cp36-cp36m-manylinux1_x86_64.whl (948.2 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a20-cp36-cp36m-macosx_10_9_x86_64.whl (962.0 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a20.tar.gz
  • Upload date:
  • Size: 575.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20.tar.gz
Algorithm Hash digest
SHA256 871765ebc07efaca98558e911970155369985641c0142e26a526985feae094a3
MD5 063d84e6e5b54cea05ed403d43e9b130
BLAKE2b-256 4a906bea1006054c23281e03edb7c652a811db059ec739c01bb0935e0d0ace02

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a20-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 918.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e2ab427e59718e7cf88c56ec1df4a4bb7dee85336804d19796f9eeb4e30070ba
MD5 5fd0e8f8723b6dd9d53d5171551e6848
BLAKE2b-256 67ec07138e88c27cf23cb129f7e81e0bab2a057fd1ece73b75a0077cb13a6775

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a20-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a20-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 937.1 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9871a8d1163d80ea92f107e438aef1b07952ddfd36a4e8320a038bc7287afc3d
MD5 a6ff9b8172433b30628793b3739fc76a
BLAKE2b-256 ed5bd450ac84d62dc03ac9b95ea070fa5e568c3088259af5c68a6b77dd487f9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a20-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 958.5 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c7f9350df0a5344d7bb11e936c421e2d140eee8f8d910ac7e0581425965b3179
MD5 318d64739fa56f561d57fda94017bb86
BLAKE2b-256 98b04c68f445799a59c5918a02a76a2d8515d6613f317f1dd7c30fb846cd46cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a20-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 911.3 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6847856ffa6c1128d831b863b0322995ec98161617d42c77a40c330373d9d0f0
MD5 d0d2739543c672fd5d660e38d97cd7fa
BLAKE2b-256 8b8b18b855e3922d013cf7380199847e711fccb3628df890ced9125ef703d811

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a20-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a20-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 945.8 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 56ee7df512c73b34da2ed6834ece566d5b8313abb89bf0bf87f5ae393a910564
MD5 9f7bd4c0767e41dea0948254819297ed
BLAKE2b-256 f27807c76bef272c3e096b10aea41d9796c6cbe3acf7443942b5b6e257994210

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a20-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 954.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 42c98a7afe73e2b9bac5f898b7fa9a20cbd5c4f0dc0b721386692a1d958c1aa5
MD5 3d5635a85cfe71ab68cc548f20ae80dd
BLAKE2b-256 8d24ffb479f5a2312ad54a6ee50f0daf8125b082c5bd2e25a823801a4dc2d73c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a20-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 911.5 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3da8cf9ac5f130e6c6be7789b5cd244f13b666b80b4f68b20283885d3714862e
MD5 8b3ed98dead96dbb077555406fdc15ea
BLAKE2b-256 adf33e2f694be8e6d3f5e6aa200bf760586347f9d5bd11bfb879c739e8030b9d

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a20-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a20-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 948.2 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f6271c019e2d922a3c1fadbde5eed2b0c67cfb1f4812f24038e3702a066436e0
MD5 c4f785aed2154f6f11228f3af4c7b821
BLAKE2b-256 0f2b95d88f18e30386ccb7e4127535c164cc7d58bd7bafae0da44e63e197934d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a20-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 962.0 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a20-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 125e75d9fe069fbc37a72060ec2811ec5708127bf6f8a2c76789e7f50f420d77
MD5 33522819131ac42d94acc642394e5bed
BLAKE2b-256 c4ee5f19d9fc2241099d5d1e98705394660d9c897ce2eae0ca698da90413f445

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