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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded CPython 3.9Windows x86-64

thinc-8.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

thinc-8.0.5-cp39-cp39-macosx_10_9_x86_64.whl (603.3 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

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

Uploaded CPython 3.8Windows x86-64

thinc-8.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.7 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

thinc-8.0.5-cp38-cp38-macosx_10_9_x86_64.whl (597.2 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

thinc-8.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (618.6 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

thinc-8.0.5-cp37-cp37m-macosx_10_9_x86_64.whl (590.2 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

thinc-8.0.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (620.7 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

thinc-8.0.5-cp36-cp36m-macosx_10_9_x86_64.whl (591.4 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.5.tar.gz
  • Upload date:
  • Size: 166.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5.tar.gz
Algorithm Hash digest
SHA256 f23ace11ba990bb03c8f9667f1f8fb387d1ef9d41e803542e54c5bb209274cc4
MD5 766c27c23b9fab4f5444a2bdd9c003fa
BLAKE2b-256 0504e5d307942c1cf41543d8f41d6d258b2c9b77c4c9ca0be9935ab32649ae48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-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.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7ea32851fc3abfa6671ff9098a46073f75b4fa994401ca72985a09e6d20c8b36
MD5 1803b34d81add0f00eedcd5dd258a102
BLAKE2b-256 a7d81a8c6be00744a0d5c49369b9a9d6f20f33f349999282506bed6ba27c6ef0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 628.0 kB
  • Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b64ab2d7962772643f12a49f1f2b85b755507b45245e519e8ca76ac2cae9976
MD5 67db72a367a849c94edfff48fe1cfd7b
BLAKE2b-256 74fa2293e714332da4a373cc67aa19ea0de0ccd9f78928c15acd26326c762a50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 603.3 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b14875a5e01d17a7c0d16e9b5e6e475e8edd0ce784aeacaeaed856374426948f
MD5 ec9d6b320e13070abdb0908a580b0906
BLAKE2b-256 27d6847ecdb34469700d8dc4ba814cd3652ec0259c072879dafc2f5fd3194a0d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-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.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5b0b4ce6dcf410a70f74f5429c7517cdd9413f6a46b6495c2c4256ba3f4f35cb
MD5 7e0dca7639e62053aeb1bd6cea84a241
BLAKE2b-256 3a60cf85933e13d67a730a4b1aaadea4641b4a835d5fcae47208de1e598bf69c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 628.7 kB
  • Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b55aa4f20e4a4097112d68bda001e5850ed46611bbd23cb303ff0fde6e76aa7c
MD5 a8c96408d748c0a51ca6577e8403c702
BLAKE2b-256 301ae6b0f88762ec78819072f402ef42e17ca27ec971fd87271c298cd4e9d4b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 597.2 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0bb4d5606f3dbc9b372ae3be820532ad602edb32481ba2903f3ae32d8e2e0c8f
MD5 6c3225f50794129b29ef7d31839dfdf1
BLAKE2b-256 d4d1541a13dbbef64187cec4f2fbfa8a60552fa5591806e29231451919b23517

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-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.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 39a189f2048f996d1b7280b207baca18c32678bee70afc253dba11ab16291438
MD5 9eef7c4f20fd11cefeff97d2597d57d8
BLAKE2b-256 eb4669a48325bf21283d1548d87aff35e6da895465487e78c182c8a0585e9f94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 618.6 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b024a62ecc1cd3d6603291b20474edcc6db7858addd31acaa7033eeaa0f3e823
MD5 d027ad4038f2ab50b99fe7fe9f5b52b7
BLAKE2b-256 3982b0f35c2013da8a372bb2948dc3fa0b840f71a8ed02bfe0b7809ae13271bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 590.2 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 af32887fadbe76b52e92c65d57ba462fd8ff58f1825ef05b4030273333460b2e
MD5 3d19be84441253d9d298f7a76e01e080
BLAKE2b-256 960926080ae51b212fd64c9020403356e4a5d294d9c14e298ebd4203927de07b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-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.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 26cbeb9b559339d6a7011089acdeb10e892518dc8b0eaae71a73308df3969829
MD5 c9ddfd5d94fbbae6526b50e906198266
BLAKE2b-256 91ee67f0bf54d52edd78212d7babd0ef188008874c905fb09b1203762454b0ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 620.7 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34822c0391c7a23457df5179fd38f3e445b6e748b92251d0b9fd1fe4937bad3d
MD5 6226713f3accfe83fc758ec779843341
BLAKE2b-256 cea27883e7d19e30758bea518bfa28ad4535ae415d87eff6a86285d1ec8cedfe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.5-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 591.4 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2a7059457f008c381c3c78a641685961b86348c8e49c76ee18628cd5e0018740
MD5 dcb59a21329175bd24899c155a62cf52
BLAKE2b-256 3f35d94659003ebe15cbf5a8ab05312be45c7b1bc5310f57898360f91d3a8ae1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page