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

⚠️ 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 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
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.0rc2.tar.gz (570.6 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0rc2-cp39-cp39-win_amd64.whl (909.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.0rc2-cp39-cp39-manylinux2014_x86_64.whl (969.2 kB view details)

Uploaded CPython 3.9

thinc-8.0.0rc2-cp39-cp39-macosx_10_9_x86_64.whl (947.8 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.0rc2-cp38-cp38-win_amd64.whl (911.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0rc2-cp38-cp38-manylinux2014_x86_64.whl (968.3 kB view details)

Uploaded CPython 3.8

thinc-8.0.0rc2-cp38-cp38-macosx_10_9_x86_64.whl (942.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0rc2-cp37-cp37m-win_amd64.whl (904.0 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0rc2-cp37-cp37m-manylinux2014_x86_64.whl (961.3 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0rc2-cp37-cp37m-macosx_10_9_x86_64.whl (938.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0rc2-cp36-cp36m-win_amd64.whl (904.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0rc2-cp36-cp36m-manylinux2014_x86_64.whl (963.1 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0rc2-cp36-cp36m-macosx_10_9_x86_64.whl (945.3 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0rc2.tar.gz
  • Upload date:
  • Size: 570.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 eca15c166b76026c6af4d3ad4e55511579fa95897791e157835529f286ede3bd
MD5 52d81f7b4f8be08e03aa2b54257ef1e7
BLAKE2b-256 ea420b131b1df1fb704082bd6d855723aed7d457a92131b6b72ad2fc2dc95cf6

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.0rc2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 909.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6a6348ae6fad3872214e38a8d8c67de902b64f5da3f6e080092da56708e2565a
MD5 7e509925b78e82b0d9c3aefdadac0b12
BLAKE2b-256 84de8377efe060e925f2fb8241e40d8c783665b316e0a799e3c89e3fab0f4496

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc2-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc2-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 969.2 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bd2609fc420a26b6b5eae59911b59463f7ad761ce33e489ecc2a4f901e836c4
MD5 2813c8b5596f01bdd3c5ce2239b89ad1
BLAKE2b-256 8e09b2b7867ab10a679f2222177f1b9335261cbc8460d0d7169781bb056f1174

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc2-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc2-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 947.8 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 60e2472b800348f760bb6c7997ec4d6e0fe625db585c34f9680aa60665f7935b
MD5 71211e7640cab46e1495acf7fea18e79
BLAKE2b-256 816403267b5f9d59ebd4a5e1181b17c91f7b9157e5be44051755e799f523f20a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 911.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 064a6100f2827d5d1ba0857f902388dea21fcafefe54c233acede770ac9bfd43
MD5 e7b8c0daa47763bdae51582ecfc35c20
BLAKE2b-256 5f15fe557623b9b1a7b9618ef0cb5469fca9aef4e406a97d7bc76e052b66beeb

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc2-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc2-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 968.3 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b33d14dbb20ec56d9571c63856520bdc982c6089504303b9d629f7bf960d5ee5
MD5 abfcfdee4e54439194cf9938eb021ffd
BLAKE2b-256 f6fa04ea76c67e7b39e1def9cf37b42e74379abc987b4087d806009760998533

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc2-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 942.3 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e8b56155a6aabed4b2e35635e7b9aa4aa84af9e09f16db6da37476a438368b81
MD5 920a75bd835ae03a6b36d8ecea319487
BLAKE2b-256 f0029805b7712381bc1742bc64110a9be3a80225059cc635932ce2a09d661b9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 904.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5e68b7f1b2befef714f174d02dbb97b02406f9871017c2d3eff9e824bf57a080
MD5 2ca5333426408bf9e715fe5ed65916a6
BLAKE2b-256 57207f92ee40cd25c9a1012d187e1d6b490ab1c677d5c3bb5ca57365cbd97c26

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc2-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc2-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 961.3 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9667ec101a5f98d50b8c7ae702b9ec29d4efce8d8dac72dd1195f644b55797a
MD5 bb3c0911fd752f8e93f0ef1c17db01e9
BLAKE2b-256 569f86a7d34c380e2e9c41f6b6250b08d23a923945e882c33d862789ac90bae0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc2-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 938.5 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ea8e853609b08a21274ada7a0cf216e7e1d85177ebf50183d4d86d1b5e31376d
MD5 99c93edcc282153fce62bdde8340ba24
BLAKE2b-256 2d3f89f430bb5e623ed66091a962c9eaa66bf4dbca366cc42f280439e3bb7513

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 904.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 4b8be6845de034af80606a0b5fb1f99fa7263564f59f730ca4166923a0ab4f0f
MD5 573dbdc8edae57d0c46529e691366ed4
BLAKE2b-256 8905da07fa153eac719f29068a9d71912874b420c495a5400312d66f9cdbca7a

See more details on using hashes here.

File details

Details for the file thinc-8.0.0rc2-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0rc2-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 963.1 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d03853e4bbe41ef87b52845478db7fdc7eb412ae542e74109d3e1422360235a0
MD5 f2585f5c9b5f6d0552397b32017bb66d
BLAKE2b-256 0a28296c5b6f4215e253f00acbd2e3ef03308a992856e10d0c546a16f0b86818

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc2-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 945.3 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0rc2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 571285e47bf000a212f2ff9b6f93dabeabc1c5b832663c6ebe2fc61b6eb350b7
MD5 2de05e57a3802a51d9da7fee3cb20ec4
BLAKE2b-256 f7caaca4c7948b157b9461f58ae92a3de43dfb9c1bcc38fd89f04a7a041eeea0

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