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 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 --pre

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

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

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

Uploaded Source

Built Distributions

thinc-8.0.12-cp310-cp310-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (637.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.0.12-cp310-cp310-macosx_10_9_x86_64.whl (616.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-8.0.12-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (636.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.12-cp39-cp39-macosx_10_9_x86_64.whl (615.1 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.12-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (636.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.12-cp38-cp38-macosx_10_9_x86_64.whl (609.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.12-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.2 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

thinc-8.0.12-cp37-cp37m-macosx_10_9_x86_64.whl (601.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.12-cp36-cp36m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.12-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.6 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

thinc-8.0.12-cp36-cp36m-macosx_10_9_x86_64.whl (602.9 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.12.tar.gz
  • Upload date:
  • Size: 175.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12.tar.gz
Algorithm Hash digest
SHA256 527c220b6a8f531521b49dc064aa645dc590c6bbc6234849fbee1abdb2378ebe
MD5 77f186228b1a853bcbd181842d3cdd01
BLAKE2b-256 016eecc80bc717cb5adf2434d5f45168da0c1401f3d2e2546e7e1b868f5e00cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.12-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 63a125404ae150cd675477d446c10b213069c7d7d5c36c1a3b5467be6d1e67c2
MD5 5c0384e69998b0e783b01962c58c64a6
BLAKE2b-256 4c78fa36d8f7c8f8da28595d7aaf2864b9e4511c46790c54c9030130a557ef68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46268fa9f031e8598e5591b2c9d1ce68b849bebc7e1a05129cbf3a083c1d43e4
MD5 4a3490ce58971518638853e031b1571b
BLAKE2b-256 da5b025f998948dd2365f797fb00911e764c583e44b3a19ddcb636ab5ef7a2e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.12-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 616.5 kB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2a21b06a8f16b1d3cd0df594636b1565abec8db698e4fa9192e61da6d3d912b1
MD5 df5c75fae238a56371f36349938e9179
BLAKE2b-256 8c0a50f70f89a04f8f6d78f3df88df458a475c11503dbf7948737df60c5ecf33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.12-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d213acb8be565461c90826524e4b96fbcb14c314c19fae24b85eba7b88bdd81e
MD5 8fabcf9f6ad4bf2cbd67c1bcb4395abb
BLAKE2b-256 87b3d49f790f64268a18a7ee4fa50861058f459f48a5136e22abe12a2be2129a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c6e9b8fedae901521d5db0b8fba8678894ff6e8f4a7309d41f281003be1ee0c8
MD5 d8c1d0fe762017acd145bd1daec81bab
BLAKE2b-256 20a42debaf3c2fb0713a75f0c952c1dec778ad559707e8df70177b927b343da0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.12-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 615.1 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 56aefd97f23ab2de73dca4012eb8ad05c1a7ca3f53e3dbae652245755945dc4b
MD5 d701397369c8d8c4a234d09bc33034ef
BLAKE2b-256 ddc3733e05a1e86aca4812e14da474469c38857d12810871b8e74d8ab4a8ab5e

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.12-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b51a5e2de9d82a1bfef59ae7e5babd45880bd1dacef9eab864f25ea5a851a3fb
MD5 f2dc484942f8644751c6975263ee3c35
BLAKE2b-256 ed3814cdfc2b8ff0bd3688ef29dd44c88e6b8bef2f5b5235de777068a4ecfcf7

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b2ec47149c305f2675004f9253b2f012887ed0ddf03a41b0cd7dd6c13bb8e580
MD5 997af63d2f32a6eddf41e205d664710f
BLAKE2b-256 254366a4439a41b38ee5058cbf494454715ab5fd15a0bcbf6caf784cba6300f9

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.12-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 609.3 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc9b000e342540f4434e98a0b1a95f32c91fc7985d7b3505483e0da6ad71da50
MD5 0da16582a717abe55e8b32c1168bc81e
BLAKE2b-256 6419ababf7ce19a05767561139fe44f3c3517c352debb408a2c40f3853a9654f

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.12-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4a3162787e1c0a6a530f11f3ba82f9ebe61d4489b56d327f583294c022feca82
MD5 231b6cf22a9c4fc461d193f3334f7d49
BLAKE2b-256 5d08270b5e86e49215225b835b6aa8cf47bb49ddb46a3c39af770604435fb640

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb4445b2d0c02a619f279581470c528f49ca89c2bc67b801b22fd59a11fc76df
MD5 46a5569bf1ff33d37c7b8da9a63e324a
BLAKE2b-256 d27c08ccf04a50e3af8fed8c5d8b65b37ef77d6900a741f67af28de8388d0a40

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.12-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 601.8 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bf232e399d0411848744af6178fe309a768434d10e9356aae5c12465a9f35114
MD5 d7ebfa0dcb94902982c267431a908281
BLAKE2b-256 ee4705b3cfd36960e535cc7a8c17f0c8c53555d9dda1e172c80e01794d940926

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.12-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 5b987a38931c17c2e52b6116f378cce4518be3aec36baf979f2177f8028cec33
MD5 78a5848edc13e6b96ea554b87cabe9a0
BLAKE2b-256 b37860e928df8435fb86fd20b240fca558059c17f215824bc40dbbe8b85719a4

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.12-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c13b572308044a518882a5e92760f8dc579bac296e8d71bb2c0a167ebd0c34d
MD5 0950c86786014c3059af293fb9288363
BLAKE2b-256 e7bbf0fcac5744c7bfea77e94d7cab0f254c05a1ebc8e6f7bd27380e104c2db1

See more details on using hashes here.

File details

Details for the file thinc-8.0.12-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.12-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 602.9 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.12-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a7e3b8760dc33986779d8119a83d4a6324fa1b38ac56c71d7de29c20bd348f8c
MD5 72bc7180cd08bc6131e7ecc2b9a5e789
BLAKE2b-256 8f4d91e37fea83d0edeaa7739dda73be4a0cfbfb2dc046f67196c2e7aa43d243

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