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 and TensorFlow. 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.

🔮 Version 8 out now! Read the release notes here.

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 and TensorFlow 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 are available from pip and conda. Both installations should come with binary wheels.

pip install thinc
conda install -c conda-forge 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.

📓 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 and TensorFlow 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.
Philosophy 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 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.0.dev4.tar.gz (572.5 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0.dev4-cp38-cp38-win_amd64.whl (934.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0.dev4-cp38-cp38-manylinux1_x86_64.whl (964.1 kB view details)

Uploaded CPython 3.8

thinc-8.0.0.dev4-cp38-cp38-macosx_10_9_x86_64.whl (976.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0.dev4-cp37-cp37m-win_amd64.whl (927.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0.dev4-cp37-cp37m-manylinux1_x86_64.whl (968.6 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0.dev4-cp37-cp37m-macosx_10_9_x86_64.whl (970.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0.dev4-cp36-cp36m-win_amd64.whl (928.0 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0.dev4-cp36-cp36m-manylinux1_x86_64.whl (969.4 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0.dev4-cp36-cp36m-macosx_10_9_x86_64.whl (978.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4.tar.gz
  • Upload date:
  • Size: 572.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4.tar.gz
Algorithm Hash digest
SHA256 25080718904cd649ff2edbf2d3093b42498c4ae4f92aee1e50e28b02c6178d51
MD5 44a57ddb67f08c9004f6ab9e81294b67
BLAKE2b-256 ab23cfdcbfc8d38d4415df9debda8dcc25a70407140aba9228e8fbc0d3129f86

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 934.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4894072ee7e7fdf4687bc9e83c47778bf0372664e08078d5d2d328e075247fb6
MD5 4fbb92505bb59270d58716932c734bc5
BLAKE2b-256 e1642dbab7c910d1f2524192649887a18c7ed41b3e9447919d97ad2b2fba044a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 964.1 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 95f8dcd7d16c80fef786e4d2c363ff17c0a6a29b5d02f82fa823abf387077f48
MD5 569a32103f4bbc295b2e9b0a5813acaa
BLAKE2b-256 ccff3d5644e07aa6ac478b6439c44c6098af32e2b96267dda89c39f8338e5308

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 976.6 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 234310abb475e6d050aa8d318814ee77651fb9fb3e14cf7db69459316cef86cb
MD5 447492760005e6fe46ca87c84d721596
BLAKE2b-256 93fb4cb44792a1445940ebaca6faab3d03e4b4a7e65715e1f92dbebe79f52ee3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 927.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2fbea649b6b93ef13435e0c7415f303fac125859ff33449f9578acdf5a05b280
MD5 3971a144f911ff5e17468d5b5cf67ed9
BLAKE2b-256 e8ab96efcfa2d2d35f640f1a0d51c5c85d31f2dcfcc9f3e52a0fef1e63a8ff60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 968.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f35f834c897992401ae85a1dd19830c4d48d8044ef0ae7caee4cc461671eaae4
MD5 4dbda63a4e4873e0e3bac218fd80b27c
BLAKE2b-256 66cac9bc5bb03d841042224b6d5fa29e52354f185a40cfeeca84e935c4f6c8c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 970.5 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 35a443fdb8afaeef582858d3cc0b0dd15ceb7647887974c2904c56a77619f9a3
MD5 9e043071169e1d5caf0b9d291cdece9c
BLAKE2b-256 98bbc403876628f752683a9b009e3cb39f103c833f6c305000b7382cf9990ea2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 928.0 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a6768340da3b26d481b4fac3a1bd19c213f77c22e40bcb904c65c23001247bad
MD5 3605090f0f3f6763a115c9dc5dfeb80c
BLAKE2b-256 0603a1449eb473fa40bcc86c160c5220141675340526eee0d28e6174c1b7eeed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 969.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 632fc2082f2097e81b7c0484059c5af62022c869abb9f8d15d3ebba15eaa6420
MD5 bcf76b8d603f22abd6ef79523a02f387
BLAKE2b-256 83e92f7ffbc9fb9f0bbf4b3ff07eace1f0474e4ec027f6df8db22add6aaa52e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0.dev4-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 978.2 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0.dev4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cf122e038fa890fba9eb66b17effe6f0b4782e77f0b347b9ffbd434fb9a19f00
MD5 b663f7b549408040c41e4bd280d38d70
BLAKE2b-256 99827d72ef641e38fd208178946dd63b6f5354363da3c9896a0d2535ef06b5c3

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