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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 Windows x86-64

thinc-8.3.1-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.1-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.1-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.1-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11 Windows x86-64

thinc-8.3.1-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.1-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.1-cp311-cp311-macosx_10_9_x86_64.whl (839.1 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

thinc-8.3.1-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.1-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.1-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.1-cp39-cp39-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.3.1-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.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: thinc-8.3.1.tar.gz
  • Upload date:
  • Size: 193.6 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.1.tar.gz
Algorithm Hash digest
SHA256 44e747bbf93e981dfded7d432b68ef1ba75b28ef46fc51f185477970743b36e9
MD5 cb2f06fb12049eea17b843b1532c569b
BLAKE2b-256 ea60b7d645d621a47d649975b53c13cdf3e66b456a24727ccd34794f1014f45c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.1-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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a31ced0d89f2b5060460f2c579bd47cb8f463213ce8bb362bb96dc5049014cf5
MD5 f66c2c2b9c540bf66dd42600a5fde77f
BLAKE2b-256 cbc1db886ec993cac0d1e568b192886eb6c3a5e0cc929231b7d473483c781239

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9e0f03229fe3810d27b56c09f6777f5d7b540c0f21c6bba62774acc4940878ef
MD5 d27765058cc46848960724ca29531906
BLAKE2b-256 d0b5bbc193639d9c0fdb5dad2320eaffe6959039203db311829e3e12b978c693

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a00487381ef8937dd9a4ca4d5985730ea3961c53969938e331eb022eefdc8a8
MD5 bf0d85270e3869d7f9189f8093e64d3d
BLAKE2b-256 8fde200f4e146bfa4c584da6015decb40f03dbde96d32984db2fc0e3ae94f644

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 53d16d08986b34849489b684ab62568516dfb852cff47f353a6f4f9b5fc51ad9
MD5 5b6e490bb224f1ee8f32f7aea886af21
BLAKE2b-256 1de3187b2ce2c5fef0e48dc0c811c3908073315c045dddde7567b41ec81aad76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f9d3beec1a90809dccdf91706e63a45af4f497c79842c6e868103f67a3c07d94
MD5 4b6a0d537ad66d11ca6827ecfed6a82a
BLAKE2b-256 d457a29266d868764bea44d849199cf570d12ee3ca4abf9139cf6b14f807b7e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 59ba73ada8ce8db0b526e1bc97352863f4c329aa6f22f968edd842c3f61ddc32
MD5 42aeb56be4c77f4e27f0a35381263b76
BLAKE2b-256 c9ac83f4c50fa1d58d8172bb2827623bad044dd6240cd1b3dcff30c220150df0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8898443c19fc0fec821059e0200c18dfae4c2a2b4726a2b8c38f768d77257eb0
MD5 d37b0d5e841742d27ca9e9dcbc92ed8d
BLAKE2b-256 78989d0fd08b34fbe9e3e036242c7ec103e308ebecaa28572e67e32d28f519f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 29d65d89432cb2ce4425c16d557c453ff1bc25c999413b254b9f7ad1c1aa0836
MD5 6e6d64d207dab271fc0362a128779ec0
BLAKE2b-256 8e467bf8a8cfa1b684dd148269d695eceb86d486b792d16e9684fdfe90cd83ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e6a99fd79fbb5ac3b389a3ae787029b8b2fbf490bbe2a48476d9632bea44a6fa
MD5 d00716d3c326c98b95bf105388861b48
BLAKE2b-256 f0e8092000c62e39f46c478656368633d33a22e4bd81bf55c2fc2fb9d2e0a61e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8c9fa243d041e7fa7957fedc82be1da588554ab7b2f76f284c61d38f4e1069eb
MD5 cd41e6166f8ab43d9805914a82106b45
BLAKE2b-256 928d0871d355dcbb1e518e584bdc830b7a6e03a472a66ee5551229fe949bf11b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0beff8bf25b7f289c693bbf1af521c33038c2cc5060570ccbe537f217101e532
MD5 3c9bcbd0c587d138a67cd6de8515cdc5
BLAKE2b-256 c25359d11538ec7b69cba78a8a2bce631440ae80ecc8985b4940ea13f76fee17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0567c8c583d83fee675949b70132a4e1e621df99964d12827282dc4d00bf0e27
MD5 0a4877b2c2ba38010e2ca1678ac57012
BLAKE2b-256 b855edc4bf276dd2c845ef9e56dd66ab23551f1814d4b42882ec1592964f4807

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.3.1-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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b405cbe7fc6f6426571c700a8aa9ad0bc6b46db427e5a2754fb5d34c5e112f9c
MD5 35bcc8eda97743ebc3bbd9bf9e529d2b
BLAKE2b-256 967b288fd3420481f2c52df7acf932eed450eb72b0e37fae89c3417a5a5d82c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f65ad59e28fb84fec5d571f82707898e6f1372b72d4d75f855835494ab3dc129
MD5 5b3c2e2c747e28c6a3bb2da0a04f4cf0
BLAKE2b-256 8a1b64036a5efb64250253d09f093ec64b3ebb533d042c79761b8328c547fdab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0c66843c0fac639997c14a36135870e08a7cc3be2cb2975e1410fcb85d5127eb
MD5 7cd9ec4df9a6249e340311878a82448a
BLAKE2b-256 2df367a7fdae9151570446913a6b31290d1dc8b1e17a7506b62bb177795da136

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d9598a797b3e59bdf0affaf0042448d1e3b2f5b70eec85b7d04a5915739104f6
MD5 f0a30d5b2c4cac7625328c5b547291b1
BLAKE2b-256 debc32f318b6cb6b03eff8f4ec52350e02d030204d728a9df6b19d6e94a870d7

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