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, including JAX support (experimental).
  • 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==8.0.0a1

⚠️ 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, cupy and jax.
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.0a26.tar.gz (582.4 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a26-cp38-cp38-win_amd64.whl (925.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a26-cp38-cp38-manylinux2014_x86_64.whl (981.5 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a26-cp38-cp38-macosx_10_9_x86_64.whl (965.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a26-cp37-cp37m-win_amd64.whl (917.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a26-cp37-cp37m-manylinux2014_x86_64.whl (974.5 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a26-cp37-cp37m-macosx_10_9_x86_64.whl (961.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a26-cp36-cp36m-win_amd64.whl (918.0 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a26-cp36-cp36m-manylinux2014_x86_64.whl (976.8 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a26-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.0a26.tar.gz.

File metadata

  • Download URL: thinc-8.0.0a26.tar.gz
  • Upload date:
  • Size: 582.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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26.tar.gz
Algorithm Hash digest
SHA256 a0bc68409d5f8782fb76dddcf0bf091dde98732f84f9d7d0a1a93bf123e6ef30
MD5 fa1e42fbc8bac6eb11a7b1083836dedc
BLAKE2b-256 0ab9675c09293d16f2e4fbd7ed26429d45007b5096548eca20f811f491dce916

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 925.2 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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 42eb6ec0bcd770a7b8f825b1b558877045daf35f5e5634e6cdead1d9ca7292f3
MD5 e7caaf8617f92cf4c1749fcddeac427c
BLAKE2b-256 da2d5baa28284cee85809ab552dfcf6529be0b735d58ba361a4bf6062b2e8b78

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 981.5 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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e38e2b86d5ee53c1f59beac1ec0bd1f8b31eced623c03401f5a4707540338a1
MD5 bb410506e3046c8da3f641b9a39093ea
BLAKE2b-256 86b3b44fcd7fffe6a60d931a0e49da4b83a85c90be995cab56d96bf66542c200

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 965.0 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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 291a5405bebc8bf550fe6f0a98ca1737f7bb8ecca79b953679463e5195db9fac
MD5 7e977eda357248dd94c7838775358537
BLAKE2b-256 91d7698d5b10c0c15890ebb05fb2129d0124e7b6dcf90657b12309482c840233

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 917.8 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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 7b8a34768442a59bb6f26101f7608912396a33286c434c813bea1722ce59c98b
MD5 a6c7d0ec3027f77fad5ff8ebc4cec06f
BLAKE2b-256 56f7202272e9cadfe8bd8168326264516e0b3dd1b329fc6b6d09ee44db57fdc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 974.5 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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 417aaa5fca28c82483422e31c07a901917a8c483e0c566799084300fb3c910ff
MD5 4bb79e259a2ff478cf71f685685c552f
BLAKE2b-256 e2bf1067e753933a50ccaa035fa99d0bd7cd26f4f55652dc4b686bd31646adb5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 961.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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2e9bb87e627a89a472d142a7a88bcab40922c46a34c6d4858a81be0cc2423f7e
MD5 ad83abe37181d3d2629337a0beabec32
BLAKE2b-256 c1bf5e923977ffb9d8621ab2e0746c59642a8530487c1bd59bc6ba6ccc463013

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 918.0 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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 fb431e1cbd921a91d7a42ca3a34e40c474ee15c91a1f6891e8a5b73eca6c0c0f
MD5 3338c81923ba9a112ec9bb7acf088635
BLAKE2b-256 9f550ad7e1faaeebf87a95a839abe52b832425e179ce585f96f0859844329cb7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 976.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.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2939e36015875f225cfa649a0168481ccc74f189d63836ab17f7024468607035
MD5 af49d427aef1b7bdb90399f152f4ea8f
BLAKE2b-256 50ab62aea126bdf25ceae12013fa287a120915fac887d944c8f5ebc70d69dd06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a26-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for thinc-8.0.0a26-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fb0fe75f5d0f953615f3e4078482a209d669cd70d6bc7fc07cca88ef16ca5f55
MD5 abc6277720120e48a988689888c768b1
BLAKE2b-256 6b52b6812c6b8d3d49cd8a2a4915bf5312f68c74ff41c6a7d93c28f80105567c

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