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 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

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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (631.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.10-cp39-cp39-macosx_10_9_x86_64.whl (612.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (632.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.10-cp38-cp38-macosx_10_9_x86_64.whl (607.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (623.7 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

thinc-8.0.10-cp37-cp37m-macosx_10_9_x86_64.whl (599.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (625.1 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

thinc-8.0.10-cp36-cp36m-macosx_10_9_x86_64.whl (600.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.10.tar.gz
  • Upload date:
  • Size: 172.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10.tar.gz
Algorithm Hash digest
SHA256 b5e4db8d24e6be8a5f1e4a17854772b79a2b560224519f50a21f3951ca24001f
MD5 f8e78cd76c09ccb01d2b5e9541a1f8ce
BLAKE2b-256 446fde85e350344a6255fd9acccdabfc60a622fe6f4ea5f628d7a39932f99e37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1019c7e4715d95ebf482d0fed0557b2cae266faed84185d5fd955e9269847f35
MD5 8347a20cef6dbe819b72d902d271d209
BLAKE2b-256 7328c1708f033b306d93951bc6ee3dd3806f59df90bad1d20ab585527f2a28c2

See more details on using hashes here.

File details

Details for the file thinc-8.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1ec20c02c731846c76197270e6780fd06050dbce317d7b5532a4cd659ce5abd0
MD5 9e00ae9a208bdbe0af6e0e3520d01246
BLAKE2b-256 32b3025757c331f3487fe667fad5c7c810d37b609052da47f125bf4da26bcdcc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 612.9 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 99fedb3350366a70fa09de6fd2fab1c0affc58892febd9c42dac57e8364f3b8c
MD5 2a453fef222f43b28a77649c5bf2d134
BLAKE2b-256 ebb72cf31ba1d1bc1b14d868741c8b8068bfe56a1d57de7ae1fee5dccffe06c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1b3c523f85bf7d546446e8f0c71f3da35d2595cbef300fccca80004f64cd0b49
MD5 ad148b98a61ff4b86c6510298411499b
BLAKE2b-256 dd92618ae8ce4ba02739905aededd00a7856844ecdd409c88ed325f2f1716a4b

See more details on using hashes here.

File details

Details for the file thinc-8.0.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ef232642683268bc90d609dba9be9cc1e811fdea5a93b371d04afd8523c0418
MD5 06571d35ee45967b5689148432d88032
BLAKE2b-256 80554287c44e99a2676aa7885856f405052aa2e4c22a172f69ef224573c190a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 607.0 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c3553601642a4e27c4ec9d205941948bf913d34779f0b075d48790a02df4c7fb
MD5 e2d25f2d99e2ceffa385b2de691c8c1c
BLAKE2b-256 27b2b6c6d976d72df402aadde18f7db9af95c1e04362e394702fd3c1599d74a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6740d750f69cbfc11c4c5e76d2c77616e3cae6a7b2778f6a680767c816407648
MD5 0c10dab7d5f148c008f2404351a3e0b6
BLAKE2b-256 58e116995127aa37ed9057afb578176a80d69afba77b6a95e3749d1831135fd6

See more details on using hashes here.

File details

Details for the file thinc-8.0.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.10-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 128f4f98d85b3657036387cf2886c3b871a4fb5a099198d7c8911b19167302a6
MD5 87139bd2424991995c80517d09b5c7f2
BLAKE2b-256 18cfe5286220208833574259d72f8fbccfe76f2b2ae516c829ccb5018c621b87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 599.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 df40bf1e07bcc72278939c9af831257bb7932b74b824cef27e38b6634a103699
MD5 81b5c1c6b90c139bf5fe3a09b08c7499
BLAKE2b-256 f91cad3ddee6011e7fc2adb39c0cf9dd8344bfd654cd5d891a54b9e7d5b9a121

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 933ebbb417d3f0fe35376500f8f068ba4bcc9528b63bd71bfa0ed0a9e137a9c2
MD5 a7e72caad31a2d8e6ad8c81f30c08e48
BLAKE2b-256 dfcfaa8af30c0023077f4cb61e156f4a6776083ccb9604ef62cb1efd78b9ff63

See more details on using hashes here.

File details

Details for the file thinc-8.0.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.10-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5f2fcbc805b27b55d31ad865450ec97433a667c2ddcc3c8a56a664425e52df37
MD5 42d23e09563d1b46967e09242e22e3cb
BLAKE2b-256 b39e96169ee3d7ee48e12aa9046c9d376ad861114ec20ed6e67b8ca68bd388f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.10-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 600.7 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for thinc-8.0.10-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 908912f2d36cf7826d7b2c466e7faa5922972c2a4f0c3a5a7d8f3dd791c80921
MD5 31f399eaff39c5c7ceb527438c66ebcb
BLAKE2b-256 fbb3823dabe95c13ee7c37015a3830403c34773625073b96d41ee9e309287e65

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