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 codecov 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, including JAX support (experimental).
  • 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.

pip install thinc==8.0.0a1

⚠️ Note that Thinc 8.0 is currently in alpha preview and not necessarily ready for production yet.

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.

📓 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, cupy and jax.
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
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.0a8.tar.gz (579.0 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a8-cp38-cp38-win_amd64.whl (946.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a8-cp38-cp38-manylinux1_x86_64.whl (975.5 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a8-cp38-cp38-macosx_10_9_x86_64.whl (983.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a8-cp37-cp37m-win_amd64.whl (939.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a8-cp37-cp37m-manylinux1_x86_64.whl (979.3 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a8-cp37-cp37m-macosx_10_9_x86_64.whl (977.9 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a8-cp36-cp36m-win_amd64.whl (939.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a8-cp36-cp36m-manylinux1_x86_64.whl (979.9 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a8-cp36-cp36m-macosx_10_9_x86_64.whl (985.8 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file thinc-8.0.0a8.tar.gz.

File metadata

  • Download URL: thinc-8.0.0a8.tar.gz
  • Upload date:
  • Size: 579.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8.tar.gz
Algorithm Hash digest
SHA256 369d8a528d50228d1e3fa01f4d8fdae7e79bcb83b6034cc542b78e8b5fe91d1b
MD5 8940f845704ad9144fe1fb17a9664aaa
BLAKE2b-256 41f050122d189e80ffcddf65d91fcdc502ed78a5e64a7acf80ed4f924d0afec5

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 946.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b8b8b919a0e19607d8ca9cb6345ba31c25af26c97bf40474ec591410f87af059
MD5 98994476d3b9220f0510134945342697
BLAKE2b-256 648407d26eb27c4438a1ab260a4bbe34e9e54b26d257ab094f74db543c81c81b

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 975.5 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2de88eb24e6229c7f50998edb163f101418c6dcb98c68630f71e6a002b9c6e0c
MD5 fac97f5bf3392c40c6e80c85fa016999
BLAKE2b-256 d7d24016ce6494643032551a84d2574658fe080e7ee9c009f4c5d2ed8c98b524

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 983.9 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ac182e8392892b5ce06617e8fadfa96a900b0c820dfabacbfea7fd3fb71c3f33
MD5 d3e6ba97d75629aae9830ad5271c9a57
BLAKE2b-256 eb4d25f8b13df9f2a77822d0fa977d7844e7c5240ecf15e0a731a6a7e527a9ec

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 939.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 689c9ac2e0a56f5a132a015b07b75d3b032256503c4103bdf9a32b98affa1b6a
MD5 b44783289fb8bbfddfc7d2b4185fbc16
BLAKE2b-256 b3f47492641096866960d73fd2f25c8e8887455a24f31fbfe84f094f1297475d

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 979.3 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6adb46de1caea7163c5d49796d888b4b6986332c23ad95fc0f51fc0982eacf9f
MD5 75bde0e92d9298a495510ec375fe4ef0
BLAKE2b-256 883f869fe3c46d39e060ee392b280adcc239b01e40d5a091b08ee48636ec32d5

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 977.9 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 870e8205808a3f73b2e3d583f1f2dcfb3f1909da8597fdf14c05328d7ce065ac
MD5 85924e2fd74d601e364dd50cc62e633a
BLAKE2b-256 71c582a22308a6a56a6aab3b151f9eff8989e32e5cef626b87835ebd06084c8d

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 939.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 ab0c2190d221ac6619ed589b80a7eb0cd18cb00fa60586875f5f67774fbd2fb1
MD5 7d7db83fe3ed1dd90a4cc1e72587171d
BLAKE2b-256 1e29ddb5f1393ed8336e9d087aa746df9cf9cb1828ae272d982cf0478e407949

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 979.9 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0b5dc7ed99312d550c6473ee6be2cae43842208ecaac877302f98bdc952a0e33
MD5 f950b1ddd32d19acdabbeadcf079b9b9
BLAKE2b-256 535d1e077501ca33ddf974b109f1706aa790340396ad982db4c096ee82d84fa5

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a8-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a8-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 985.8 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for thinc-8.0.0a8-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9e0878b2fdbbd94b0304545cb9dde16d847a892d15721f3a0c94a229d29c3516
MD5 ceee3226f16155ea44fd63468e2b24e8
BLAKE2b-256 8e187b6756fae427c0fba8ffeaa7cbf5c7c851fc8a2d0635c5b7f9ff970eacca

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