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

Uploaded Source

Built Distributions

thinc-8.0.0rc4-cp39-cp39-win_amd64.whl (912.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.0rc4-cp39-cp39-manylinux2014_x86_64.whl (971.9 kB view details)

Uploaded CPython 3.9

thinc-8.0.0rc4-cp39-cp39-macosx_10_9_x86_64.whl (951.0 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.0rc4-cp38-cp38-win_amd64.whl (934.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0rc4-cp38-cp38-manylinux2014_x86_64.whl (991.2 kB view details)

Uploaded CPython 3.8

thinc-8.0.0rc4-cp38-cp38-macosx_10_9_x86_64.whl (965.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0rc4-cp37-cp37m-win_amd64.whl (926.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0rc4-cp37-cp37m-manylinux2014_x86_64.whl (985.3 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0rc4-cp37-cp37m-macosx_10_9_x86_64.whl (961.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0rc4-cp36-cp36m-win_amd64.whl (926.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0rc4-cp36-cp36m-manylinux2014_x86_64.whl (987.5 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0rc4-cp36-cp36m-macosx_10_9_x86_64.whl (968.4 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4.tar.gz
  • Upload date:
  • Size: 572.6 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.0rc4.tar.gz
Algorithm Hash digest
SHA256 ba0ff4346b43f8ec3c6fcc0a8caebf144f783256b9a3165ab05335b83297d6d2
MD5 4900cc72d7fdc25e16d9e21f1ea29502
BLAKE2b-256 6a282cd1f9f2095579f9b880aaa78e01bea3403c9de7182f57cf3eb490f041a8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 912.9 kB
  • 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.0rc4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e064e4b24835054f44b8aeecdba71b48c871ce4bf949d474e1602b54bdc8ca4c
MD5 1a96b4255038f6118cde9f52d89d06a7
BLAKE2b-256 28090e074bd226afb0398ecbd466c5ace866085275a4b14f42db7562c034eaa6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 971.9 kB
  • 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.0rc4-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b85d920e9ec6e511e292410c179291eecce7e9e9cbde8a24ba220097659b22a
MD5 2eb2344ad00fa1e019ec278817f5246d
BLAKE2b-256 c6924c21102baf1013618ff902fe41003040d0dd00fffb4e5d54c1bb9293e0c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 951.0 kB
  • 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.0rc4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 54cd97ccb2afb30745aa533826eb084ae55f43276fa6667a4af91eded010fe2f
MD5 4c59bb3922e9f79b8e249544fc2ca54f
BLAKE2b-256 701e888c363bd03f770157007790c18af0db3948eacb0ebb678102658223c0c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 934.4 kB
  • 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.0rc4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0546254ac9d1167a60439dc6d9e77e5cc657d1c189d949aba600e79fad50bf3b
MD5 a1590458bfd84c1376c9bee022605842
BLAKE2b-256 33c3054362b98c2b0cf1f0db1a2521597c4f87c8602458d113ea3384f5228cb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 991.2 kB
  • 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.0rc4-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 680cfd764b6b2558ef678d605807630245018b2b6412011e6a686b1e069b05c4
MD5 712840e4a39157d7f075c284bd2752ac
BLAKE2b-256 a0878c3c92f0505d5faf1a55aaa71968c81fcd90f534db74801385603ed93de6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 965.4 kB
  • 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.0rc4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 855d5ce6a78c50618ac439a1fe63b33be2ae50653dbe85b3e8faf1156db72a25
MD5 215d467bb94ad1ded006b79f9b371568
BLAKE2b-256 c7e8a7f991e9e40cdc28ac6dd92be6796d3e708700df03502f0ff35d75fe37fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 926.6 kB
  • 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.0rc4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 da661e45620bb3d43e8f461c42da00781586f1b1b8e416d5ee9605d38e8b5523
MD5 da84f6ee276b0d9fddada17148cad4f3
BLAKE2b-256 2cf64bbc10e8b9a8f50e06297ee94030b2050efd3dd7edf64ed01dc27ed7ce08

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 985.3 kB
  • 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.0rc4-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 604972a88c204ea0dcd35e26e675a34b7807f597663f2f2ea44f85d72697a9b9
MD5 05dec64145e35b4b62d3a465792aab6a
BLAKE2b-256 9d22818a8c65eaf9a8378edb16c1405ef610e0f33cd74cb66d1f7a38a52d1efe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 961.6 kB
  • 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.0rc4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 323c2383cb3b2c1934c586fbed919773940d86e04078dc00f82ff6d0d5a1e5f9
MD5 58a3781f3ffa224ec805cb21689a6b26
BLAKE2b-256 01852cc951fd20685614a04463cf889c214e18053913ddc67d62522dfa66dba9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 926.8 kB
  • 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.0rc4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1b4243337898f6c2e72fa696a8789df91cc9a32a778d160a804461e983af088d
MD5 1f975bd1a07e32d421d76abeed25344b
BLAKE2b-256 9eb8861f935b79f67b205b0ec834bde19a957bb4d3a7993151e75a43deeaa4e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 987.5 kB
  • 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.0rc4-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7aa764f167b8158ab69b46ed875812cf2a75df9666bd93b1c870d641c51fc2c
MD5 ac43cd0ab8aeea8899dd0ef6a9743ff5
BLAKE2b-256 4c0a1840a85cb04dde79610db728fbf5d33995a8b9fe9c64a9e3e2a2b5769e1f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0rc4-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 968.4 kB
  • 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.0rc4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0118b0cf407c083740a431e407a7e4723fb1cd346d44e6e3086ed7d6c0bb26f9
MD5 4fa0bcfb758d52665a0a8d1319468ee9
BLAKE2b-256 71192071c22238fa1716098e2d3247a2f833da7eed27a9d9ae3bed304f4a869f

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