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

Uploaded Source

Built Distributions

thinc-8.0.0a32-cp38-cp38-win_amd64.whl (927.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a32-cp38-cp38-manylinux2014_x86_64.whl (983.4 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a32-cp38-cp38-macosx_10_9_x86_64.whl (966.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a32-cp37-cp37m-win_amd64.whl (919.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a32-cp37-cp37m-manylinux2014_x86_64.whl (976.4 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a32-cp37-cp37m-macosx_10_9_x86_64.whl (962.9 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a32-cp36-cp36m-win_amd64.whl (919.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a32-cp36-cp36m-manylinux2014_x86_64.whl (978.7 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a32-cp36-cp36m-macosx_10_9_x86_64.whl (970.3 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a32.tar.gz
  • Upload date:
  • Size: 584.1 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32.tar.gz
Algorithm Hash digest
SHA256 cee205a2150d3a295a3446fbc173969755bb5299945a34261f1dae1f650fc95e
MD5 792417bd99acfc62e061e54af561c3fc
BLAKE2b-256 d7515ea5b15651d78eca58a546366d6b29517ead9761e96d4e5937013be3ce61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 927.1 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 aa6583818ceff1273e85d3e113ef8d08bfe134c23568bdd2f3307d44b41cddeb
MD5 495d074e4a76e69987d48331e421dd13
BLAKE2b-256 4bca0cfa2b9d30cbea5df766570bd254e9ba229b355a263be67da4c17b2df007

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 983.4 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff2a868f216fae3558d5e1fe25a2750590270eb72090e907f3e312627b55faf7
MD5 12ac1366708f70f575a35072b6e812c2
BLAKE2b-256 c91bbadd86b7351f983dda2dc4b0b289eb80652b3a69095ab2f655995380984d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 966.9 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8a7b265572474cea661b400522f3b5cca469acebe8f58edde7eb5e8ec34cfc39
MD5 ac608d3c1ebe7066c2c4b13c683a5bb8
BLAKE2b-256 cbae1b21e524b4b0f9317888a62e569bdf9fc0f7e85d2fe815bd9d0d39f97dca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 919.7 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5d7846c1b656e50f84f0b4f8f40b2a76cd9bdc50dfacde4432de5ca218c7da10
MD5 6bfb6f663fe313a94f30ad695331591f
BLAKE2b-256 536f1d11046fe75da24bb5fd1f6a023558dbf1b1aebd41a9702c2fe83d37df34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 976.4 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7569474e4d78dfeb8e886b55e1a024a10beb0c45c9a6fd2844b6e195972ab7f0
MD5 3e26f46098e360c6fbbe98880df84a40
BLAKE2b-256 8d6d8e48848a4a95cab619c14106ba3b6a3bbed4909afdd15e5f1419645b3dfd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 962.9 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8c9d8ea39b90c4865dc5b210e3fbc49b7bcd6c19b0e19171a47b43f36699b021
MD5 77c8e2575683e72792e36eb5591df1ab
BLAKE2b-256 32a5f0815608abff8461dbe3df71204131ccc6ec7b7af13539d16982e7c331cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 919.9 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c8d42c092bc599f1c80255ed245e9fb34c750ede18ae2ad3283dc8569919414c
MD5 962261fef7fcf8859b63df7da8aa9c14
BLAKE2b-256 c7e5b9a20a2da03c628bb481c679b49b332b0cd1aca877664adff816e9348a4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 978.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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 df2be94aa678317382c33ff7dd1e18852c80a7a3f6d59ee7dc33e5a71ea89ec2
MD5 0f9fa1ae75e98fc0026d499d422df1eb
BLAKE2b-256 c4f09ccab845bffa0579d568b52f09866ee89fc9e13fb67adda2656982c3f950

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a32-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 970.3 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.48.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a32-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 205dbe4ea94c3e7e97063f15fc2044c495efc859141171e9d2d52eac45d01866
MD5 e4aaae88cac077aeaa9067e247f83d32
BLAKE2b-256 e6d136c59211deffe9379f5b8787dacd75ca3e23f4b296c5f18708b58dc26a7c

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