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

Uploaded Source

Built Distributions

thinc-8.0.0a2-cp38-cp38-win_amd64.whl (942.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a2-cp38-cp38-manylinux1_x86_64.whl (972.4 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a2-cp38-cp38-macosx_10_9_x86_64.whl (983.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a2-cp37-cp37m-win_amd64.whl (936.0 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a2-cp37-cp37m-manylinux1_x86_64.whl (976.8 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a2-cp37-cp37m-macosx_10_9_x86_64.whl (977.7 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a2-cp36-cp36m-win_amd64.whl (936.4 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a2-cp36-cp36m-manylinux1_x86_64.whl (977.7 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a2-cp36-cp36m-macosx_10_9_x86_64.whl (985.6 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a2.tar.gz
  • Upload date:
  • Size: 576.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2.tar.gz
Algorithm Hash digest
SHA256 6ceb2801dde864f8c17fe6a578ac0e2161df1639b13143419f50f906a0366628
MD5 ebd003415d88c17266a827b06c944c7f
BLAKE2b-256 75f59aa6b0a70b4cb98346da186de306a7e38d0c9e8315631080557dfac8c79b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 942.8 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 af57ceaef05af77d2ddc81ebc90cd6e4453c99644a0e4325da36af3e43520c94
MD5 f959ccc4177982e32d3fc09e334b21de
BLAKE2b-256 ec29ea91c8b96632e80ec662e848ac3cbe4a3ee4c1271b39008a546224a9f64d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 972.4 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8d06c04f0603c656eb54f5289eb0ee855ca829fef62bfdee2953c375d1af6347
MD5 52e3bd1c17c4d33cfab189a4c4c6f43a
BLAKE2b-256 8eab182991d5ecbaf9ec7508bec4fb23f22b9f133a97aff5325758027d131480

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 983.5 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0624979aea88b38db85d4df7252fc73fd7aab84962036f07fcf5b8cd862065c1
MD5 7a5792fe34a6810012baf33e5bdc3d1a
BLAKE2b-256 b1e0a9ed8f28332e3f5722b6da5a3224af36a244d2caf8a776240cb6a05268cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 936.0 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 058d2c1163fd00f639321b659b731ed42054a8cfda03a5eb322a28baf6f40ae4
MD5 0dbe6a37423508920d43c3a6abe61336
BLAKE2b-256 71f3949abdc90077a4c8923fc80b11ea3d8eec1ad4ebb561e344883a9955d3d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 976.8 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 03ada248f7d8a6bc6a33a8b078bdc6ef8348cf3cf6462a628ae67d009443fd8b
MD5 cb8530be0fa5670f9770edd353c1e0e8
BLAKE2b-256 333e0633d12ff0ee80d1d6419dc78b4dbe91639aaf2b5083b5adc3bba6140ce5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 977.7 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4e1965fb671780dc65ef7e3ec92ebca8b73c69dfdb4dddfffa03f401e9a4983d
MD5 c0ed5f4e9ccd913100cbb0dabb7e76bc
BLAKE2b-256 b98c2fcf85d7c7161acb9024a7c48130e4fdb886ae977f46a332f1d14d6bb59e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 936.4 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c5227e477a033d9f59584882a8a348c504a7a8f4bba3761b2e56680a8817a4d6
MD5 2449210d0f44b7e1dd0c9ebca396854e
BLAKE2b-256 87f97a44e21c509635a42cc9b59f4c0ad2262c587aa77ca0d8554d5f317a1397

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 977.7 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 108486114eaab36a435001f789966ec9558925493df177515e50a818eab24cac
MD5 88e8a1b5a46697f3fa106ba778216960
BLAKE2b-256 ab9ea5606d7bb05418c44c48fcc665a1fbb5e18814f860bc9dccd24891a58d49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a2-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 985.6 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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 30ead439125939ec48a77e83016ecf31af945c71fa1da89cf1f2399cd691f4c2
MD5 ccee8f4a6ae233ed28729dc9e231aa30
BLAKE2b-256 e1eedfdefecdd6559b8488c88e49b2b5754ba131eb2757c047ddeb5f4e579ced

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