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

Uploaded Source

Built Distributions

thinc-8.0.0a33-cp38-cp38-win_amd64.whl (916.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a33-cp38-cp38-manylinux2014_x86_64.whl (973.0 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a33-cp38-cp38-macosx_10_9_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a33-cp37-cp37m-win_amd64.whl (909.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a33-cp37-cp37m-manylinux2014_x86_64.whl (965.6 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a33-cp37-cp37m-macosx_10_9_x86_64.whl (951.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a33-cp36-cp36m-win_amd64.whl (909.4 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a33-cp36-cp36m-manylinux2014_x86_64.whl (967.6 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a33-cp36-cp36m-macosx_10_9_x86_64.whl (959.4 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a33.tar.gz
  • Upload date:
  • Size: 574.5 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a33.tar.gz
Algorithm Hash digest
SHA256 bbc8f70260590a569abc0c0503a07228620309d2a760ea387f9fcf7f73121062
MD5 232158257cc168c795d4fd23e6b3e6e7
BLAKE2b-256 28746af8bb15e5943aec6486123f74bdf65851fc7cfb8c2a2227c2c8e63acabe

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6a55ad2d2e418bae3efa38dffb0582ecd12eb08d05b055a8c4c39285c937050d
MD5 24a92cd4710405d64c73984a6c2267bf
BLAKE2b-256 d72fe19ce7f69c10c97aaff3a7a1c19a6c0e14f0814715340eb061afc8920708

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 53ba6a7d271405fe402a45f4acc64fff05900484e705c1cc59eddf36cda00c5a
MD5 d554c24c88831041db783c73771ef7dd
BLAKE2b-256 a9df02d992bb9699e229697fc04b4b224864f626b70346e0819636d3623be99e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5eab116d3f659dcd2ee6ad2ca412868c65986333f292ca9d40feac47aa469eeb
MD5 c409fa2e3bec1cb57b0bf6cb987128b6
BLAKE2b-256 837199bbf94659c11daaab43ca1e303bd851584597914260abfb263aa9be771a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6da4edff95ba31e6dba96511b2dd55d5adaae5cbaadcceee92e982c372d4dda5
MD5 1d201352ee665d74218a5abd928692e9
BLAKE2b-256 4f00b5e148937a236c798e836c0f0121c25f63810fb597f97e2c6d3a3d30081b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c3c7fc37dbc4cf89f70fdc0ed66b049a41e5c5f8da507a4c623ee1f10b5b39f6
MD5 ab429c368572579a8ac090c5ff9f5c29
BLAKE2b-256 e20c2f1e16074879eafc6543265623bc48805b2ce2674108789fcff572ac9e6a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d9575d2a92f536e3be7f515e83d1046e94ef6d5b4922aad5f7d4d4c93a2b4ad9
MD5 16c6ad356cf7608dae2da0c2c4709404
BLAKE2b-256 cc94af1d8520fd36e88c07b436d5cb3ed7d058e8faed15edbffea867855de746

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 691453cfd26751b47a939c7137856c302b47668b998debc0c5ba7b0c3e067fa0
MD5 88a73dcdc5734ae9b52f4d460c586ef9
BLAKE2b-256 be8a17887f5faa5e7c59211d5342e6b3fca982141cad3d73e5e8453cbf45a017

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab331b3c75002181e17f72b1564819b10b529414d0635a2a874cc82f41194aa9
MD5 a3fa820066a2224793f514e1e57005e3
BLAKE2b-256 af0806c79374f5e72600968c21f23168b32df5d38bf4c1a4d9dace6acff8d950

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a33-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 769511c50beaabc3f418511ea02b37768d0cd8057ac5b34be00a630868a80e80
MD5 21c8761f9417a1ec1fa13f9268458ac1
BLAKE2b-256 8049d5f56b8f4e85cad272c9ebbc08ae8b3881486aca40803a12a398c43bc2e0

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