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.0a42.tar.gz (568.6 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a42-cp38-cp38-win_amd64.whl (909.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a42-cp38-cp38-manylinux2014_x86_64.whl (965.5 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a42-cp38-cp38-macosx_10_9_x86_64.whl (948.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a42-cp37-cp37m-win_amd64.whl (901.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a42-cp37-cp37m-manylinux2014_x86_64.whl (958.1 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a42-cp37-cp37m-macosx_10_9_x86_64.whl (944.4 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a42-cp36-cp36m-win_amd64.whl (901.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a42-cp36-cp36m-manylinux2014_x86_64.whl (960.1 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a42-cp36-cp36m-macosx_10_9_x86_64.whl (951.9 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a42.tar.gz
  • Upload date:
  • Size: 568.6 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.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a42.tar.gz
Algorithm Hash digest
SHA256 564b4a4fa5279a4b3dcde60530be378bdd4a01391a99a87974a8209f58a6ac65
MD5 dc7b2d2ff2b007c94dcdbeeb4a007914
BLAKE2b-256 e0400739e00b38ddd2972b63520e2ffdee38185f71c25b2fa7475c75e03a98c4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ba556bda074dd39a5177eccd14482bda4d371621cfe284b4410eb81b0645fc8b
MD5 8eb4f1c45a938aded6759ab3e0514cd0
BLAKE2b-256 8fe49e7740b608f1f6299d8a166ebc72c24acf9df260864b883172c95597560a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca7eb5553906d3fd9c0eb1f7bc36a705fc45c8571e61c7ac9cfe3bc59df2e0f1
MD5 873ecbbce4246e7ed1fa982fca84640b
BLAKE2b-256 df8db9b5b0caf05e736214e7138b6df3d95caf5be0510a7440ed59a1e9546ec5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 138501db242309b7c91884537aa00127034fd705806fa9057394cd5ea899b585
MD5 daeb4df575b317e2f600417a707bc3fc
BLAKE2b-256 075d3a0edd8bd74ac9a19db6795f928d9270ca2a1a5f444b139ed4ddafa8092a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 88d2a8d3dc8afb39c14994714bf8d06fcdc59bbf61105f459259a78b837a24da
MD5 7ab76ba6143b7d4f6c5a3ce5ebf42cf0
BLAKE2b-256 809c544fbc394d3b37a286605399961e472a562848cedbf21c1049aa13005c5a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2dbb475e5c35b4944ca123a70f5367ed6c3c2811b0322e2b0a22875bade1099a
MD5 9ad435f0ce5d7c6bdfa163caae7648ed
BLAKE2b-256 a8b7fa01ebeceaec4690d8b268b1365f9e78dcb2e1bf6d3fd8b699672ec1c06f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 614c9f7abfe150dd9f6fbdb2d633342bab32de2d83703a119858993cd75d45e6
MD5 7d683f02b0ae156fcd007ef4d23f4e6f
BLAKE2b-256 1197492863cf174139ba789ea34479986372d901ed00abc26e9f89d0c7914a01

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 922e99d84d95156fb43794a5f91c7f9565aa0c49abb11881ec7ba2b913731324
MD5 a4855acb6560c36266d37545f4d0cded
BLAKE2b-256 b756711b5d87cb2fa262cc2e91ca8e4a907621ba0d905f574efbceca2efe98bf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 75c20ccfae0b5b66d1cca975eeaa37164c8a2fc537410a88eefe7519a4656582
MD5 24b8289a806ce8bc47b9b7170c4a2987
BLAKE2b-256 e4835cef21d929a56e374b0ec614282abab947d9db0ea65d58f122c3f51b162b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a42-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 998ac1dd069108882cf528f4e4c3f6267fa53684102f410ee49d30f675fe0479
MD5 c4663f3300a65f21cae072897cb2ddb9
BLAKE2b-256 d28c5fbab9326b19822afea1d8179f3bd2da73d583693b4040d27a4749270664

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