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.

pip install "thinc>=v8.0.0a35"

⚠️ 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.

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

Uploaded Source

Built Distributions

thinc-8.0.0a43-cp38-cp38-win_amd64.whl (907.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a43-cp38-cp38-manylinux2014_x86_64.whl (964.1 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a43-cp38-cp38-macosx_10_9_x86_64.whl (947.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a43-cp37-cp37m-win_amd64.whl (900.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a43-cp37-cp37m-manylinux2014_x86_64.whl (956.8 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a43-cp37-cp37m-macosx_10_9_x86_64.whl (943.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a43-cp36-cp36m-win_amd64.whl (900.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a43-cp36-cp36m-manylinux2014_x86_64.whl (958.8 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a43-cp36-cp36m-macosx_10_9_x86_64.whl (950.6 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a43.tar.gz
  • Upload date:
  • Size: 567.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43.tar.gz
Algorithm Hash digest
SHA256 dc388aeaa2027aa9f7f5f528a679958460b7ad6453419ec633414d0e6e3ddeda
MD5 494cf78a8202dafd1a2b01883b6b9ec4
BLAKE2b-256 e2e3fac8688d8671333936e3438ed35a9a1d115cf1d2c1f3b5e3d2ebdf853549

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 907.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4c991f423ef1850168395781593e428aa457b051e60098371c2bfdb8cb31ddbc
MD5 14cb08fd0c5bac88e696d6ea7fbbbd85
BLAKE2b-256 b4cd00a586b4453c85a2cbf487ac041daa196aaa2df4b90c7950d1ff49a6dd3c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 964.1 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86950528ff244eefde1152a746ff36e3a2b469a63e1224209265581dec63e4d8
MD5 d6d7bd1a7d45bd35e3e2d0c1c2108b0b
BLAKE2b-256 1c19befae00aad1bea4115e5e37ace6289199080ed4cf78c0c4f11c750c06734

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 947.1 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 807223954f179b74f028985ac847419bd5c2eec10447338c01a4d75f5478112e
MD5 119ae272d2d2a90ca3fad8b655dac868
BLAKE2b-256 cdfbfe050e2aeaafa7227479ca68f1cd451c6609a23af7751df624f126df2ce1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 900.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9d4f048af766b227a53e0ffe11b06bdee4159f40486687a021e055e52e0ca618
MD5 7e9896de9bb8bbef6876a5a517a23367
BLAKE2b-256 0c44f0fe2bb32e0d73f62381cddf35cb432cb2f8f111436c2f932bb5c97ae03e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 956.8 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5426faf29875e3a33151699242e03fe43ac2eeba568a703590556ea96ec1dabe
MD5 6bbf4b6b8d87cbb18002b182700c5646
BLAKE2b-256 f7a5ae5af6dfd4ecac62978664c5181541a38eea2bea2299fab8b23e4d76c238

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 943.0 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8660f0df402b724cce78f771670ff1421d0fe00a5488fc0a54da4d35a0fe237b
MD5 63501846e32377423f2ba0e6f017ec11
BLAKE2b-256 f6b55975f93c86ce6ff4bfa7d63b3e8c20cf7485b59cae6f29367369b70d36d9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 900.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c105d982b3634a8927578ef7ee398a0fda1a41225a1ad8cd6464972e7474818f
MD5 a1f72cfc063b7dbb964890b2753d892a
BLAKE2b-256 7b1494b46ccd575e203721604f5d52047b1793bd003ed1cab82205e75a232890

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 958.8 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 56ab6206d8b93e241654719c0f5684821c70c7a09bb2aaa8c6ac8c3d2c523973
MD5 cd1e7c435c8f1fdf1c3906fae6b2f888
BLAKE2b-256 b860d8a538dfd23b944ddc41a8e073b9803d7c1ab39031c2188d8cec435a43d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a43-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 950.6 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a43-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fc8f46ee810491254b2099feb8ffa38006e42ae1ec8d82aa6bbeab11cbf902b3
MD5 e1cec82782161494875b4a71a5a25305
BLAKE2b-256 6707526fd9b6be9ae348664a1cc801440de9f298908ac0206578f78bce87e024

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