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. Before you install Thinc and its dependencies, make sure that your pip, setuptools and wheel are up to date. For the most recent releases, pip 19.3 or newer is recommended.

pip install -U pip setuptools wheel
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.

⚠️ If you have installed PyTorch and you are using Python 3.7+, uninstall the package dataclasses with pip uninstall dataclasses, since it may have been installed by PyTorch and is incompatible with Python 3.7+.

📓 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
pip install -U pip setuptools wheel
pip install -r requirements.txt
pip install --no-build-isolation .

Alternatively, install in editable mode:

pip install -r requirements.txt
pip install --no-build-isolation --editable .

Or by setting PYTHONPATH:

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

Uploaded Source

Built Distributions

thinc-8.0.0-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.0-cp39-cp39-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9

thinc-8.0.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.0-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0-cp38-cp38-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8

thinc-8.0.0-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0-cp37-cp37m-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7m

thinc-8.0.0-cp37-cp37m-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0-cp36-cp36m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0-cp36-cp36m-manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6m

thinc-8.0.0-cp36-cp36m-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0.tar.gz
  • Upload date:
  • Size: 619.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0.tar.gz
Algorithm Hash digest
SHA256 fc3025baa14fed197c5f12ca71319dd6a0cd262e479c6eafe5e4a0440d8c9e54
MD5 96277e333d3b29a266023a3f4a993c7a
BLAKE2b-256 f9e18de0f964ddf728e814c438a679481ff91999aa49040c488b0595ec9522c4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 557e6380686c3d2abaf22d8330a0b47f413e410a1c3b8ffe9c43282ef83519f4
MD5 ec5e4fd829200b2af6057424d236aa8c
BLAKE2b-256 c6ae33f073e6d66a7b579aff1bff1b117cdd6aa8f96a827b1fb12bef9e44ec5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4352c83cb7a1bb4a2cd214e2855b6e7b6b1425614e43a7fea23dd2099746877d
MD5 5343757e84e8521ddd75a73b123ff2a7
BLAKE2b-256 bfc54bb1f25bddf69683e457bbb84cc7e737565a3925297034c7c7e12d2f5a1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 989e8e1a303c322d30ae799930b734563697effbdd672c04ce52882c06bfdcb3
MD5 4c25b41e0f513ff4aea8ff7d8975d90e
BLAKE2b-256 82184424254eb08d4c4a849911cf21a300fd9b8fb95e7e0e154641991789a4b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6317ddb8524ab5d11d1f3f68d657dc7c76af6980271c4bab9f702a155e94465f
MD5 d0fc2bd4c6262242c14e92340974365e
BLAKE2b-256 c18ed912d4e595ae214dc5305317cd8d76f689ad6896812a21a066428f9383c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d570a58c34837801e8f32b47f9dcfbf4c69c5eb55937944f8d9fa0279ad4f6dd
MD5 ef97df260a898c09f799c495f3af2539
BLAKE2b-256 b663128c718ebe37039ab9f6d1c3c5484c8719f99e6cfb0639c5f35dc20ae43e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2403718a247e76c40eaededb6db3fec9b9b0803adad1a89c950f29708aaf0fdf
MD5 97b43778369b556347b0f4a3ee893963
BLAKE2b-256 4ab8b3fa3acc027b2b4b61125310cc913c0d0869d11e311c049f6e54d0d7757d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 fd8b375177ecdcaeede39b1247836efd2c16b3d8fc9cc33486266756c0e63bde
MD5 9515d3cdd0c85d1cfe289e21a689e787
BLAKE2b-256 b422080d160c37f9de6877ff7720a49ebf6c3d3d51d62c22391f799d8047d048

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b19c9dac53edc6931cd94e3badd5226c0254083fe778553c7d2c47143a38af8
MD5 131f8f4383b0be1d5bc2beb4862f8b4e
BLAKE2b-256 385a19feea753154acb7e7a4541366b458842c082dd7dbad7435436759165832

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bdd33fa4147586df0826ace2082be3be023fbd1818982afae3dfb43ef11e64b8
MD5 8ad94e6ec5ddb918dbe1e95946daa590
BLAKE2b-256 352c55a5a16e771f497d6ab8e635343d4eed3376cb519d3034716164055ffb11

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 ae367efe5aaa32ca87f956b1ced1dab746079f3fbe092c1d72beab7164a99461
MD5 077fd1ceef52ded9e063e5fe3e6123df
BLAKE2b-256 ecf1598f55e609db9f5c6f888c569b9b891eed5f18d0f09647ad9d2da1a40fe5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e30433cf9f1174115e81a0a7cbcb6c005761f1e0945cff2c22b26d8b3018666
MD5 b3cb26f9c66752230226f7ca442a6793
BLAKE2b-256 77a2cb1d3d37cbebb5adb252a80293f3029e8be973bd394315d6bbb96efd2653

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 37fbf14732f5de6f0bd4426c2d1d4400fa6c21dbd1b9809ca54a1cb9624b96fc
MD5 c1cb61cbe96f085cefd5fe628792a9b1
BLAKE2b-256 8c56268a43bfde15e2255a4e38c45d98dd16b14c44354665a4050c24aa8cdc30

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