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.

pip install "thinc>=v8.0.0a35"

⚠️ 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 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
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.0a44.tar.gz (568.0 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a44-cp38-cp38-win_amd64.whl (907.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a44-cp38-cp38-manylinux2014_x86_64.whl (964.2 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a44-cp38-cp38-macosx_10_9_x86_64.whl (947.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a44-cp37-cp37m-win_amd64.whl (900.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a44-cp37-cp37m-manylinux2014_x86_64.whl (956.9 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a44-cp37-cp37m-macosx_10_9_x86_64.whl (943.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a44-cp36-cp36m-win_amd64.whl (900.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a44-cp36-cp36m-manylinux2014_x86_64.whl (958.9 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a44-cp36-cp36m-macosx_10_9_x86_64.whl (950.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a44.tar.gz
  • Upload date:
  • Size: 568.0 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44.tar.gz
Algorithm Hash digest
SHA256 232530766b257b4cb9257d8e1bc6aa9a05ceab6c4095afb5035a6e892104fab4
MD5 7f46b30727c057a53c50f20fe15e2cdd
BLAKE2b-256 48bc52e0030e7787b12c3285bed3f8bef7b3612aef425d03329db0502377958a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 907.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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0d1777fc57b9d7fb528b0adb8253592af869a59786b5a80aa56ae7b04c84afc8
MD5 0ae523cb14077cde39ee2e1475c93a17
BLAKE2b-256 974f01619435815e0e615779a0fa5327ee833e1231afbaf999c354469a8ad86e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 964.2 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9702e67b965539c1971d020e7fed1c0874be8034fe38fdf1a27757a18d429eb8
MD5 4f41dcf3d942d2cb9b144c047431a1f2
BLAKE2b-256 01ddb95c9b6767170c2261b135c0c944eb1793936376b29b4c7b9b328ede5d69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 947.2 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fb461de8e43ba895d1b9b11006bb4441cf26bf21dbbb4dd8f49fa79d7d9f2b58
MD5 8fb03ad614f84701bb26db37cda224ef
BLAKE2b-256 f0e61e92574f129b34e8c3136bc6321d66fbf820ff606582e5faa4331778cc23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 900.5 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 cdca1225ce700486804c27454ea38f6f1f8915a7c48402e413569eb6dd4f3346
MD5 ece3c6a0a248c4ad80e8c12eaba932a1
BLAKE2b-256 1345a669296061514f19ae9103f852066379417d7e07ed4b13d66faf5aa6d986

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 956.9 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a878e0b5624d073931778f2f2ee411643db2cc2bb6f1d8e92043fdccf67aebb9
MD5 bbc20ce8aec35e8f4fdd9e7e78eeff1d
BLAKE2b-256 d0c3075524c27a31efe16ce127c64c860c99f239ff6ef6231ac34768a153100e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 943.1 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 49445f26ddee430d6c49154d952b519ab0520a0a769ad2214d1afeab0faeddce
MD5 c2a6820be8c2d381f7a8a20f336e85cb
BLAKE2b-256 a9aafedf8debdb28319234eae06151cde137a67682d92e80abc3cab7bba95a82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 900.7 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 85bf22866f6b69e493274e00f58a7079335283469814861b83d00274009b63a9
MD5 a6c4a454970ed4d30071ea200fbf4fbc
BLAKE2b-256 e01a89082065a5e65a440b1bbc038771e099f418d3c19b391bbe3087e470e4ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 958.9 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3d7af4ba6b66ee6f4c01e5c2558729f0d7c25020d1d3f629c58422ee4ff2761
MD5 51118a8c8f048b5d32ff44dcb7456849
BLAKE2b-256 a99c98bcb5c8516f8cfcebbee912773b018201d70942dae05f24399fe8b3e18c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a44-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 950.7 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.50.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a44-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 239218aa50ff90116624ca245271832e20b6e74ccea192e21b0813deebde897a
MD5 eb8562d4d7f22e35080dae7bc8fe04b5
BLAKE2b-256 7485628775392035775d8b8c55993d65bd48df9207f196bf249f3d9eb8a635f1

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