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

Uploaded Source

Built Distributions

thinc-8.0.0a34-cp38-cp38-win_amd64.whl (916.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a34-cp38-cp38-manylinux2014_x86_64.whl (973.1 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a34-cp38-cp38-macosx_10_9_x86_64.whl (956.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a34-cp37-cp37m-win_amd64.whl (909.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a34-cp37-cp37m-manylinux2014_x86_64.whl (965.7 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a34-cp37-cp37m-macosx_10_9_x86_64.whl (952.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a34-cp36-cp36m-win_amd64.whl (909.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a34-cp36-cp36m-manylinux2014_x86_64.whl (967.7 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a34-cp36-cp36m-macosx_10_9_x86_64.whl (959.5 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34.tar.gz
Algorithm Hash digest
SHA256 72e3d6c888c657745ef972c9949110eca198b2c0e5dbf5edef08652660236c7f
MD5 8785c3ae8b5ffab41070ded070273674
BLAKE2b-256 d5558ad25f0702164967fc14c9367361d6c67b275f7c4372de85c9441e98182f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 71ebaac5c4c32c7e8463c805aa6591c045f98f999cbda99795adef0f300d578b
MD5 03c2d26d7f071e90c41612de9ce17f1f
BLAKE2b-256 77bbbcdb794e6a56c55cd55371a2cc1b924a867e499109b9e36c65383d68a178

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46672928b88f6e5cee99c60d23f1d1a9c0ce307db1c8065f45fde205459c9464
MD5 f50ca53e2e31a35c82b963a91d0035b1
BLAKE2b-256 2cb84fdcc6c2f26f3b3b7bd5bdd8894e93a4da85785d01ef37994c813584b37e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bca0ca32a465a4f301a8a231ae4240615095f386e33c131dfed63c0174f53031
MD5 ae4bbeb5ffec8b173e6ee63503438498
BLAKE2b-256 120bcc2dd813efcd4b212ad7822e2b6132873abbec4765b34ca9124ae67f43a8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 50d37459283f1d9be2797ce5a89fc68b6d1472a1e0f625a46d6f40e6094f4723
MD5 97576944bca92d645feaa370a184b82b
BLAKE2b-256 a7eeb59c81a2f60b0bbbe61bb0f8aeb2a55af45341f219acbd840eb8a4141418

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2e46cf553f9e5314141c97c80a2c8ad9369506c9584fed47d7ca54d17ffbaef
MD5 520f7c38e809b9bdda0dcf5289922130
BLAKE2b-256 fad505eff2fef6d833a5327427c4464e1bc616c8584acf288b4fecb982599527

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ee1b3a92f4719f9e8a4cd5d9aff03d5787a7e2a44a9412781c176ff6165ff569
MD5 c446a601a365620526210b08f8a413df
BLAKE2b-256 bb7ab42213dc8cf4a90c2bdd0c4ca3a045a050c9c2a94f4a72d194960bf17755

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f297c8b38fb3a5bcf34aeb9cf660ff8a39697f9f299e01f53fb8e08adfb55c8e
MD5 41f24d529f2df063a7e6f750711447e2
BLAKE2b-256 4fcd6a7fe207e859a737f1a198dee5df82e6ad296221e66471771f62df7e2be0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c4f5d8c5681ec9ccd2f030fb1389fd6d984a5acd2ca59584d5e48db0578afad8
MD5 2e7ae6bb5b531dfec264809c1e7b7aa8
BLAKE2b-256 cdaddc6aec2b12e94f659b427733602171c7c53658caca01b458b360a0f2bdad

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a34-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 82a7e511c17e4f3353263cc97a4e9ea52b74ced9e9fe2ec99ad8263339dfa323
MD5 96680c3a62f7c38d7d0d5f9704b7d6de
BLAKE2b-256 9a47f39620942ecc87dfa6102bf2333cbe699cd6532f089add00c63864b5459b

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