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 and Prodigy

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.

tests 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. Before you install Thinc and its dependencies, make sure that your pip, setuptools and wheel are up to date. For the most recent releases, pip 19.3 or newer is recommended.

pip install -U pip setuptools wheel
pip install 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.

⚠️ If you have installed PyTorch and you are using Python 3.7+, uninstall the package dataclasses with pip uninstall dataclasses, since it may have been installed by PyTorch and is incompatible with Python 3.7+.

📓 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

Documentation Description
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
pip install -U pip setuptools wheel
pip install -r requirements.txt
pip install --no-build-isolation .

Alternatively, install in editable mode:

pip install -r requirements.txt
pip install --no-build-isolation --editable .

Or by setting PYTHONPATH:

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

This version

8.3.2

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.3.2.tar.gz (193.9 kB view details)

Uploaded Source

Built Distributions

thinc-8.3.2-cp312-cp312-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.12 Windows x86-64

thinc-8.3.2-cp312-cp312-musllinux_1_2_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

thinc-8.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

thinc-8.3.2-cp312-cp312-macosx_11_0_arm64.whl (761.0 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

thinc-8.3.2-cp312-cp312-macosx_10_9_x86_64.whl (824.3 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

thinc-8.3.2-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11 Windows x86-64

thinc-8.3.2-cp311-cp311-musllinux_1_2_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

thinc-8.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

thinc-8.3.2-cp311-cp311-macosx_11_0_arm64.whl (774.2 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

thinc-8.3.2-cp311-cp311-macosx_10_9_x86_64.whl (839.3 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

thinc-8.3.2-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.3.2-cp310-cp310-musllinux_1_2_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

thinc-8.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.3.2-cp310-cp310-macosx_11_0_arm64.whl (779.4 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

thinc-8.3.2-cp310-cp310-macosx_10_9_x86_64.whl (843.9 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-8.3.2-cp39-cp39-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.3.2-cp39-cp39-musllinux_1_2_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

thinc-8.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.3.2-cp39-cp39-macosx_11_0_arm64.whl (780.8 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

thinc-8.3.2-cp39-cp39-macosx_10_9_x86_64.whl (848.0 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file thinc-8.3.2.tar.gz.

File metadata

  • Download URL: thinc-8.3.2.tar.gz
  • Upload date:
  • Size: 193.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for thinc-8.3.2.tar.gz
Algorithm Hash digest
SHA256 3e8ef69eac89a601e11d47fc9e43d26ffe7ef682dcf667c94ff35ff690549aeb
MD5 12b0abad6ca4d35e14b4268fd9820cf4
BLAKE2b-256 8a9fb2193b69dd112a46800182e897cda2fc9c497dfdd9352a0c5ba9252cf5f0

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: thinc-8.3.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for thinc-8.3.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fe8dac2749db23f8ebf09d7a7f29e1b99d67e7d7b183e106aa2b6c9b570f3015
MD5 3eec0a4a5c08edaa4b2140d9d0adcb02
BLAKE2b-256 e49bc0b21db9dd0711164aba62b7d33f794fd55260a88aa9fd0262bf7ae535a5

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ae309b0788478984eafeac4e3c33a2de84a6ea251fd1e3528d8018d4b4347247
MD5 f35dff78a149247db3a24ef229fc733c
BLAKE2b-256 79bba802cd2e374a55ca24b8f641dbeede03873c8c00d00b8265c6961b42d48e

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a80384c228ac6bbaf4ab7f7c9ca4a53c6053f2fb37b2b50c4730b9057f07e9fd
MD5 abfbfa05d42977ab6b92075498997a52
BLAKE2b-256 508a4dcf7aae62c208b2decf65c03ab502d096b848f59f7dade00dbdefd952eb

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b014a282e9ea6330a678b472d74f479c7a38168cbf570bdc740e50d960dd78a1
MD5 2b15e1572df19bb0a7511e4bc9574bc4
BLAKE2b-256 1c8b123d6221b9bc115f609363b3477ff5cade21f480d7b88aff566353c8a74c

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bce8ca6a62ab82f4595210ba7f18bbdb6e33561277c59060f2f04bdb93ac4fbc
MD5 4ed4f5596a8428302111faef462e796b
BLAKE2b-256 235005880c76826e659abb230fffe7946de83cb87ff96d8aed8944a05de286a8

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: thinc-8.3.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for thinc-8.3.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 813942d59881c4e4165ce95fef37ba30ce3366dac43289697d13a952a8208854
MD5 b079454ac5e3ce5912baa295adeeee2c
BLAKE2b-256 2c31e01fc596219714c6ad54b7fad8c806f757faecacbd9da2b56a336c60b67c

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ef0868e55108f05300f4508e6896ae4e9492f3415220e3da65579f693225816e
MD5 8c9d02c7a9b2b8e4f10ad5177df4d05a
BLAKE2b-256 72e434de6f428e1db75d0deda6e1117f5f45dc31e42be995b4f268885bd356eb

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed88275031dcaadd85d3deeb8eb12d1ec0ee6b4679e24cc893c81a30409ac4ee
MD5 37ccba7f7ad3dd0667c95cc7872c0b5c
BLAKE2b-256 2322398b073f48b45703ba32344b3075d37371fa5343369f88394bd21aa625a0

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 54a5411daaca1718a73982767b714c1d0a5e142de73c916367baf1c13d79e8f0
MD5 c7f3e328b1b374aeb7a3bef8771a71c4
BLAKE2b-256 a4f1698e1dde83fc517fda77ada67f9e0cb2caad8eb69f50f6bd188921ee1b51

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 12e998780f40d36d4d5f3b760ef60ac60637643f2965ebe1948801ba44261a03
MD5 f559ddf85707858582c4debfef38a047
BLAKE2b-256 fe2b3a393bbbd62c845801bdec94aeaa0f9c89d9f269d19ef7e5f7a612cd99d9

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: thinc-8.3.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for thinc-8.3.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f96c274c4119c92fb8fd8a708381080d47ad92994ef3041c791ed6d4b5c27761
MD5 6ea9e015fa2da67b0ce8ca30496f9cb7
BLAKE2b-256 7548cecb8525bc354637ed240035a51cf7f7c469bf0c8bd8d6dd0d107d376d74

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8b46786063787a60a0d732a5d43d0196f632d3d35780c8fe1232d1378b1b5980
MD5 892d220b7e06910e20c164f810d8650a
BLAKE2b-256 6d493108d6ecefb98f96b8274940cc0d82119fbbbdc8c6a898906d76c5b8a1a7

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d471e1261e5e650f93cfae9880928c2ee68ad0426656f02da4490dd24716a93b
MD5 d90e669fbad8194c2bf3a3b63941f202
BLAKE2b-256 1e16c1bc8e32ef3912436287a450f1c7cab14ae1a5752976b6a2a82ca93c96e2

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8b753b63714d38f36e951241466c650afe3177b0c8b220e180ebf4888f09f5e
MD5 1a332d29a9624d56a603d988ebbc7719
BLAKE2b-256 1fc4005491c2d4b73674ff31aa23e8b5460b63818dcfdf4b28a36dbd07cd97b0

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6af5b1b57fb1874079f7e84cd99c983c3dcb234a55845d8585d7e066b09755fb
MD5 57f6b933126313713ee51ab4e7d7f2fa
BLAKE2b-256 355abf0fa7c80e0d584e4145ffbb1127a3aca751ba51482cc1f05c1e0e0b2a62

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: thinc-8.3.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for thinc-8.3.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2977c4811b7612984ded795dce182419b9f3058a1a55c191f75024ec2f4cb218
MD5 2e96acf5a27ac79f121ad2f92626e393
BLAKE2b-256 51cad03b1af37795a23cb22060ce507f0fae83b666153ac6033a133eb7f4377e

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d701de93d6d6bb029d24088d7f8cb8200f486658fd08dd859767b5eda6eba268
MD5 a34ecefa2e99a9ef44e30e35109f0ff5
BLAKE2b-256 ea96fe80c48d3d308892850fcfcecbc5dee05879a682229cccd5eca1b7f172cf

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4edb20939c3a157beb386aee221a5e1bbfb7ffb90d63d22c80047ca0fa4d026d
MD5 724467fcd899ed145d2742eede30fcce
BLAKE2b-256 e83321b7bc3e28bdf5eb30a068c865b23413ae9c389d430e6d25b06f6ba50760

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a6b507b1fecd1771fc448aa27dc42d024e5799d10f1ddad6abc6353ae72ef540
MD5 dc3a15467980c2c12736902349c067e3
BLAKE2b-256 9b535a83d3bbe9dbea2198f3b13edadba5a0f7552ba14e8d81bfc432e288e996

See more details on using hashes here.

File details

Details for the file thinc-8.3.2-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e4b1e4149a3bfdeb308cee4b53b07d234e5b35495a7f35241b80acf7cb4a33d3
MD5 124ef0f5d4b491c4894d6308bb4fe8df
BLAKE2b-256 6c1f505459020ee1abe244e50e10757c4f71f827bcfde6e063cbde1647cea8fe

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