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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.8-cp39-cp39-macosx_10_9_x86_64.whl (604.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.8-cp38-cp38-macosx_10_9_x86_64.whl (598.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (621.1 kB view details)

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

thinc-8.0.8-cp37-cp37m-macosx_10_9_x86_64.whl (591.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.8-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.1 kB view details)

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

thinc-8.0.8-cp36-cp36m-macosx_10_9_x86_64.whl (592.1 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.8.tar.gz
  • Upload date:
  • Size: 166.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.8.tar.gz
Algorithm Hash digest
SHA256 cf2abbd99c56f21b8804f31f995460515d95a5c5988be39e0964469e0070987b
MD5 70581c0d224c762b4c8b5529f84a7186
BLAKE2b-256 4ab5c6fa6b59dae1f007dc7d4270d2c9d275473d6c9c1f092353a2159e54afd0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.8-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.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 998b87d6cd334b5bf080ef5594bc0d1afda36d088deffc1caf7e8fe0bae553c6
MD5 35a2d726586ed3ae82446aee505417d7
BLAKE2b-256 0e6d7250f0cc817b376c7ffafbe8182ac45d4bf09a5fa2c3587ec1be42e1cf98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c37c96335d74b34e8128569070c0e17e13a213c9564a3553e44c3769a948a35e
MD5 c9f8794acc3445b784b72860dd09a01b
BLAKE2b-256 682814b2221d06b57da34abdf30ca51196159aa282a938bbfba15e766673ea69

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.8-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 37c31b83f46372283d5f394db9272d35ec6c26b8a0481f1b1995f9ed0cb72a47
MD5 fe7d59889da9934da58f9834e5ae1ef0
BLAKE2b-256 cb48f795164a25916218eb6e64e990b376d4bd839e432b11931a278772a17020

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.8-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.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 793cb9113b36df6607089806d9d08b371748b201dda05150f7f531cd63df84b8
MD5 6c06b624e8fbbb81ccb2d483709945b3
BLAKE2b-256 958a0b991e6291b6fe1489edc502782f42b214c147d6b224811aae4e3c9fd4cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03a0e2679363fafe0c7312dc9eb46697b6fa3e65ffa7a1702ea369e93389fbfd
MD5 0cd69d13b5fe856f8baab151d6c896f4
BLAKE2b-256 5abd60d6bc0eee8b98b77933d933e3d65ca26eefacf055a43894bce4fa3b20c3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6901e6d7dbb5cf08d1877920e893fe6d721627c946004a495f77c151bf07eb72
MD5 8ac8044b176d358ed66e42f53195f60b
BLAKE2b-256 f6a1f9efff26a2d2310b5ca7e8491780b5060ebb4ffee2b01d928a243a6be0a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.8-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.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.8-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d0f46905fdd737a8090609ddc54a48f70fa997e5b304d8c362db93b95365646d
MD5 c408989512d8aae5096d5e763dcc2e42
BLAKE2b-256 89f5e21c401f3119b8c65843fe731ce81e357178254ff0000b45628b90a27dda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f7c5381e804d641fff39061d3b9e01feb25790282aa8ed6684c62b8e2731e7f
MD5 32236ee2343e1851fc3694d1ff04e656
BLAKE2b-256 505550c9c599941f1a385ad4fb0cc111176fe3c03e8dcdd1b40504895a8604a9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.8-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e35ff1cea8b1ec73fed5c04923ee88ec4799e7948496fe7eca1f754019da87e7
MD5 bc6dda54d9ad845d2e16975d646b9490
BLAKE2b-256 1366b4017fd5d8b13d88da103418c741fb586c9dd0d7f608978b0bccad5c6523

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.8-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.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.8-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 101047df534a4861ba6fab25a1849c673c83536e067bd917ae735aeb9090fb52
MD5 7e288a62db09153f477913ddb2d2aa9f
BLAKE2b-256 ca5000f93eeceeb97b82837fc42887703ed392d03b4cea69f4f4e6eb8cd236ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.8-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6d0303de94e12cd288fdffebef97a460fc95700a527d4e898548477be5406a25
MD5 302594db457f31330fe0262c2854c9ea
BLAKE2b-256 a38dc739bceb4ecb63694a4ae535dd90055619726b76eea39ff59cb9dc31b263

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.8-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 68401890470062eaa3bcd0cd0bc5ad52a6fa77da87336a927df18c21dbf0ba30
MD5 584cc879571b08477cd1fa6f50196117
BLAKE2b-256 0444c481acaf9fa19e40a31bb5986be08d50d0d7df31e33e2fe194a4070697d0

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