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

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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 Windows x86-64

thinc-8.3.0-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.0-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.0-cp312-cp312-macosx_10_9_x86_64.whl (824.1 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

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

Uploaded CPython 3.11 Windows x86-64

thinc-8.3.0-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.0-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.0-cp311-cp311-macosx_10_9_x86_64.whl (839.0 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

thinc-8.3.0-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.0-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.0-cp310-cp310-macosx_10_9_x86_64.whl (843.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.3.0-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.0-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.0-cp39-cp39-macosx_10_9_x86_64.whl (847.8 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.3.0.tar.gz
  • Upload date:
  • Size: 193.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for thinc-8.3.0.tar.gz
Algorithm Hash digest
SHA256 eb3bed54f5c00ec9addaaa208c51ccfa059483d73140cd515aa33373715c6e59
MD5 06a1a2537dbd88cc44673a5c76867a1f
BLAKE2b-256 150a250f7fa34632616bb4fc37decbc46ed09243bade708968dc869d8a4c144b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.0-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.0 CPython/3.12.4

File hashes

Hashes for thinc-8.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5b7822fb53e41c9067eabebc0d418089637c94a1393a6267b0cbb5b04a464b84
MD5 f80f0a236aeabdfd9004dcf7bc799728
BLAKE2b-256 0fad34ec845e515d85e3239c0a904b7bc2a2ee970bce3b9ca000e90d0f19bd7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9bcfc3a946ace58e69e86b1977ee1b8167e917ce02db021b5e2ff2c1d558a3fb
MD5 ced0c8126efc39d63709b79198472a0e
BLAKE2b-256 726ac0fe2be4b48b49d80b43ef83a7c18ac06793abb1e484daeb773d43f4e393

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ed4331de94fd6db1dc0dda28931f1de69483bf6a14a2cb74526b8300e8e501c
MD5 e6d8c6154feb5cb63307835dadc0cec9
BLAKE2b-256 583108df7575771b262ec699185bf49b83979d4348bfd2e3cbf6713e16ba4b74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d7aa1ace6e2110ec8b88bb75ffede7163ea9643bc6c7e6745e9c12914fb312a9
MD5 fb7d9f35e5cdc1cdd47865d37f9ecf5a
BLAKE2b-256 62dc3f1d9a9553313889f2068c4326993522dca9ef3ee7ea3d8edc2d63416476

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.0-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.0 CPython/3.12.4

File hashes

Hashes for thinc-8.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f8432cc0cf9ecb72e2e37cd8b002a25dba22f044b7ce5039c5744c3b758269a9
MD5 f007297ef664e0cc1ff1155146bccd10
BLAKE2b-256 df05387922f0bc9df9f4dddcad543f6e836df8c8e969dc6691007ffec9403729

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8e1051d67657abb957e9fcf86a249208411c5cadf0ada724eb798c761dd67420
MD5 d983a3fc653e849aead2b0ff73b0e8c8
BLAKE2b-256 acfd1d4557254926b3538845e58f5a3dd086b7fee6be63bafa35bc09c0f15537

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e942d2a83becffb68275c2e32e6de2a92aa3b4ebbbca6911654b9846b4d5d8fd
MD5 41810df018832d4e163f1e01f33ec517
BLAKE2b-256 a9c3964b3d3594eb3f9ef1c212327bd616d1026e4ff658de79d777c924db3dbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8611178d797b78c2dfebaaec443e5fca4e1ab26d957a70ede4d1597b0ed8faf5
MD5 b9657963a05d8d676256019b2803f2db
BLAKE2b-256 06e851e7b87ad08c644825cfb95823eb612c68b074f051b8f03b6ce495d9a9a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.0-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.0 CPython/3.12.4

File hashes

Hashes for thinc-8.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 62e9a9659a9e62eba151c820fcf6f71abd0e68eaec83fbdf7f51dd8863437cc5
MD5 84945800f3045598b0c67c2ac0eb133c
BLAKE2b-256 fe62da6b0ae8b1d4488fef1fe81c6acf42651fd0ac87b42e55b5043143eadcda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a35303c5a579886aeea9ccf455487893f9d4d2e91ee0424e57367a91d3e66c24
MD5 0b33178e522a5b1d5bbbf655dd858b18
BLAKE2b-256 dfec0fc4d8d56dc9e1bf53aaa6d735345712afbb2c5941ab0da49446d02bc812

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 559fe1d6373037d34cbc1a17985aae0b60989218475a0a5acc4cc8bac4ee0de7
MD5 6e134f60e4b365a7b162ac8f81ad7147
BLAKE2b-256 93a596a6bfa2dbba37385ad130712fc202158f8b9d01242e32c174751bd35aad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 53e0501da5f26621d0458a12a8a4a466d750e477651060da68ed5837a608fc13
MD5 66861a0d545dc2d1bf076ba2b8ca6b17
BLAKE2b-256 6c5f32e60b9296ce4d2a88494aa182d35f462633729823225734a53e44470869

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.0-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.0 CPython/3.12.4

File hashes

Hashes for thinc-8.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4f0cdd9803fe94968eb157efc2dbf2d5e1ef98c1aa4d48b4008a0810234c1154
MD5 259284d311297b533561195fb4953090
BLAKE2b-256 0a2dd37c6d0d3f395696d3d250ac6031eb1ee6ba0880c5ae0e0c6d37e368f3ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 df03b5c0974ef1d7de7b3a30700901a9b2c7c3815830e0c10145c13e550ab265
MD5 878fd919c7d2278bce4a27d9dbc4ac15
BLAKE2b-256 6bcc47de2ade4d9e812e579f953247e7944c859219ed7e0a47d63673bf6b10ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a92add0a9789c6a1f838ce997262a0ef441fffd44a21919ade3824b957d0e6b2
MD5 feaa7b4ec345bfc2fc338c351fd3127e
BLAKE2b-256 904378066316d476c303dc36957385fde2df19d715abe9814a2bd1393135d70a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cfffb2ba86febeaf4d70f3ba147098dc7d8a919139fe8347beb94d98038258fd
MD5 ad7bf921257673abd7a6c461d8cbd04f
BLAKE2b-256 d5673af1d2ce47a8d7715d44d484559aaba81d06b039ba7fa5426b0160fa6ef0

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