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

Uploaded Source

Built Distributions

thinc-8.0.0a36-cp38-cp38-win_amd64.whl (907.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a36-cp38-cp38-manylinux2014_x86_64.whl (964.3 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a36-cp38-cp38-macosx_10_9_x86_64.whl (947.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a36-cp37-cp37m-win_amd64.whl (900.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a36-cp37-cp37m-manylinux2014_x86_64.whl (957.0 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a36-cp37-cp37m-macosx_10_9_x86_64.whl (943.2 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a36-cp36-cp36m-win_amd64.whl (900.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a36-cp36-cp36m-manylinux2014_x86_64.whl (959.0 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a36-cp36-cp36m-macosx_10_9_x86_64.whl (950.8 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a36.tar.gz
  • Upload date:
  • Size: 567.4 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36.tar.gz
Algorithm Hash digest
SHA256 e7050003353953e8e921305b518b457dab34ac208c33c0e8ed595e3586a784db
MD5 cb1a59bce8cfe43887ea5a50afe29e1f
BLAKE2b-256 0451d8df882ec2bf6a82f0fbf420cab767dc031d65017a21fe1f076d8f7c5ed2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 907.8 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 24b6972c7d706cbb301e13b3fa97e94b5e60560946646fec812527f2bdddfa80
MD5 888730e0e12ee0d23c054b080ea1d619
BLAKE2b-256 72a65e2d5d8e9d41139badedb747361014e127d106d732d2cb2b8e42bb78be72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 964.3 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8dc243878926b1b65cba0ad91eff93aeb40821e067a028a27bc7a6b619440f41
MD5 d8616666023594b74e88bcbaf57a935d
BLAKE2b-256 ca375d7a0cfa915ca8820e41f87d017dd46eff5d962e9d72d526c1f86ccfd78f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 947.3 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ae3ffb3e00d7566bdadcf774c376ca9e3054b492aa607217462a82c755b03da1
MD5 09726d6dd5f2ca5836047c79f9426f08
BLAKE2b-256 4db6c1764a112731706e0448f598891811869d44c0a89af3d3203963e13beaed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 900.6 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 8ad9887da06615b4795d3b4d8c4431f874898834d662d24155e92a21a25affb4
MD5 122edc28c9747bb5d65deed4f5d8b46d
BLAKE2b-256 a870ae6ed7da064061e20d82bb1ea8c458e87a1fb44336f487d92f3712755d56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 957.0 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7e54a997f5e99acfb93678ea449c8213e829060893e3e486f7a470171e25c27
MD5 8ca1ee1ff30875329439423af9193095
BLAKE2b-256 109bde1ab281acf20387185731f4d313f7e833d132b751f88a3f76f23444fac4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 943.2 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b4b7fdd6cd37400a99ee8af5fe7a51a5654f8d63a0ef442a8d28d2a2c53d59ed
MD5 5f8fa6242d4ceb3310d705e6acae9994
BLAKE2b-256 ed787a9817ba61751690205a1a6fc9a3562334fbc139f177d9a5055335600d31

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 900.8 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 87f048038982d62d4fd4f86a894d37c787075f24fda8ffbe2fe08c30f489f214
MD5 ca710237bf370acc9865d9f8f599b313
BLAKE2b-256 64b8c03c015915b0fa16868ec47be80ec0b59dd7cd8cbbae878fe35410f4aad8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 959.0 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4326fab14d0891df0d80d31f45d5ca9773615b73c910e3208c9f4583fff26121
MD5 7a1e2425db5ebac6dfeabc307137caab
BLAKE2b-256 6a0ee9b5d12e7eb63c37d4fd04231a952381ee9e6af7f6e7548b0c96e570f0ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a36-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 950.8 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.49.0 CPython/3.7.9

File hashes

Hashes for thinc-8.0.0a36-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b91945fe11e1c6d0bff6b774e82c6e8d1c7e0b5a2bd2ebc6f1f0e1494a9d91ac
MD5 075a60960cf20e5c254e851763528146
BLAKE2b-256 33c2664c4c539a8bd67b4a9716746736755d4fe1dad2c4ab91750642d60f5e31

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