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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp36-cp36m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0rc6.dev0-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.0rc6.dev0.tar.gz.

File metadata

  • Download URL: thinc-8.0.0rc6.dev0.tar.gz
  • Upload date:
  • Size: 618.7 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.0rc6.dev0.tar.gz
Algorithm Hash digest
SHA256 6c0f08a55da317271bf8375e13520a7dab89d7a2c7b5f59bd3dc01ed2e1cbb20
MD5 ba0a0bb48b9b01099a1dbdb3be012e26
BLAKE2b-256 5a64a562f75f64bbcad33812eb8fd9e5b619f1a4bbb11d8af96700d4324cbcc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 36a808fc4446a73394555ea548131bb75f8db1cb7904f0bb221c888a07325a78
MD5 5b1ee964d8749683262e7b4d5d084340
BLAKE2b-256 f1dbda30ac8dad3087d2418e4a8de9460f5636d03f3cb570b29b33f66886554a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 08008c5e51bdcaf06efaf16ba22a5d811d9c151a67abcf720729f7973b597e39
MD5 1e2dba79f220b85744125f5ddc6dcb0f
BLAKE2b-256 16edc0be4964bdca94ef217dd7aee14afb1d2dcc9d05152fa33066ffcd2dd48a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c26bad8bd25683fe5ee012e31f1680256badece86f906dc05c4169d30ed2491b
MD5 707404473201f94d7b4ad5125a9a38b1
BLAKE2b-256 1b40b7c07551909e04925fd5ff8662814e9e1ce2030dad138c6b0b11c8fdd37f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dc9f107ceb3654e27a78780262072ece66cc88f8987d2b6f05fd44faff6c64f3
MD5 3ebd00572c2ba7a654ea24f30553379b
BLAKE2b-256 3d3ef314425038c05cbc41ff58b8171c56864051c32486b1e6ac458970261a87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2cbbfffcfdc1d70a1ec667273a9ca05829f29a4b9c21f5d267dab2178374b562
MD5 727617653b964ed07bd0aafdeabf0f14
BLAKE2b-256 16f894d813e86d70961a7a3f06f0b7046b72d2dd30a5f844ab4574a8e121088c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b56bc83f9d9551ae1bd379aa41a428d109864f82c48d0be9b0b70d5030f23083
MD5 798f3cf07f971183d7d5dac691d78c55
BLAKE2b-256 b5faca12838753af4db2d4a2e51734279c9ca7778cf31a9ac9c5b935f5f3ae2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 563bda4ea9f12f0728876109b8835aa86cc5ae3edfaf77f53dbdf524c7914f6d
MD5 e34ba36835c9d6afb203dec61fdcb8aa
BLAKE2b-256 f55d895d3c295f7f35b9694215d3a790b2e084ef06be80f19a5d77e7f9dfae09

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47cb123cb61d54c21cfc42be04fd0b162942d0aad1b1386f31653686417b1f00
MD5 331a02f98e359cdd6ec71543ee8cbb92
BLAKE2b-256 c8ebfe37127364981370de741cb2f3f3913f8b0e4852ed054d0f6959f9d041dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e12d56b3136f21c3e29017f543933e013cb2b71f207d650945b6cdc067da23f7
MD5 292b6f447b40c7d56e62c4c94e22218f
BLAKE2b-256 c2aecfb30157557312350d7f251a3591810ae2b27427ca6f18690b41d5233ec1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 5e7c59fb8cff1c91be5711bea6c622ff14f8cb5d245264b7d80c032d123f759f
MD5 83073dfc6cf55643ce40faa97a9b36f3
BLAKE2b-256 73d0ce4bba2769cc97acee777144601b3939ac68c957710a9519d7fd87a6bdba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba7a318661a58b9a1e0ef0bef085fb21404c0a9ac75ce3b53dde6b6567395984
MD5 77ac61f64cbe329f8fe2b68e7e0d7b84
BLAKE2b-256 39bc2f24bf006d7b7187329f214bb21d73719e0c1d913a9eade2ccc32b5cb535

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc6.dev0-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.0rc6.dev0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 88d17d3c493c5f355bd6c2c99be693f1b3669274a4a2a33152914b6d71344f3b
MD5 3766705eae8d5cdbe9925f257aa37eb6
BLAKE2b-256 8d4e0cef817d75c233f2c10d3e913a8737e469a0cc330cdcf341dd8893d5f910

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