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

Uploaded Source

Built Distributions

thinc-8.0.0a22-cp38-cp38-win_amd64.whl (920.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a22-cp38-cp38-manylinux1_x86_64.whl (939.2 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a22-cp38-cp38-macosx_10_9_x86_64.whl (960.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a22-cp37-cp37m-win_amd64.whl (913.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a22-cp37-cp37m-manylinux1_x86_64.whl (947.9 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a22-cp37-cp37m-macosx_10_9_x86_64.whl (956.7 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a22-cp36-cp36m-win_amd64.whl (913.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a22-cp36-cp36m-manylinux1_x86_64.whl (950.3 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a22-cp36-cp36m-macosx_10_9_x86_64.whl (964.1 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a22.tar.gz
  • Upload date:
  • Size: 578.0 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.0a22.tar.gz
Algorithm Hash digest
SHA256 b0514e54876d2c77836df28ad4628b66d1532ac889c348c931c3c78f6e3443a1
MD5 28fc591f03198a7f3015ab3d24a9f02a
BLAKE2b-256 39865794923f26076f11bfde595570432a01429e487240af9d7a00ccaade0a7c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a22-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f5c132ba826d1a7415cee08d02f88f214ec490e505bde181854961bd9784164b
MD5 86378b1b5598f5debe56a421c6800570
BLAKE2b-256 d61f61b5031c0a0447f8b8cd427c3109303bde4d7cf3cbd08337cc7bc4fa17ca

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a22-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a22-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 939.2 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.0a22-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 92182ebf98c657ecf4a08206c1b9c4be077f7afc37dd1430feb62ae0435ef14e
MD5 c6f2c55247b1bb0a0a3252a617861e71
BLAKE2b-256 2ebf8d55b1f0b722633f65b23f9fafa045f52bc9bdea2d4baae56d870f300ac8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a22-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 960.6 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.0a22-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f515b9fc8327070a71842722643e715913ba65b542fd07a6e1f6ca50cc70ef0f
MD5 4453f6fdb7fd2201b43c6b2f96c25705
BLAKE2b-256 1ccc6c761c6a4b4b990a0e7f0bc388762309c3b7cf055e232214779db0c672a1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a22-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 38d0f15da77988d2bf129faae14dec1a36bf47419679ef12ed13aeb50cc3f58a
MD5 6746ef049fc7546159427f567fb4c5d8
BLAKE2b-256 c16c077f88959d53b66d8c6b82a91322a4e715728393839e2d1d69f081385a42

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a22-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a22-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 947.9 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.0a22-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b928c48ff8530e104c6d595635d9a7fb3ce50a6764919db8eb878f2f0075a0eb
MD5 aa7ade7a542e1b33f9c1c8adcaaac7fe
BLAKE2b-256 080602b5469fdbaef813a5f45665d6fa85c948c530adc4ace0a02646e62da883

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a22-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 956.7 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.0a22-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c703e011aa1d5e171de05e61af19e145f854c8baba3958ece8ba4f651a75ff9b
MD5 b725d4b8a86a08fa89c89107a1cb91e1
BLAKE2b-256 f0c60ca68cda7d96aadacd51735d4be02f3e698add35c3fea844ef3b48ee76ec

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a22-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 be687d321886034bf4a28750ccb6a386822bcc1a8bade90767a032daedbb1344
MD5 fd1bd7c8acbd2032eafbde170529848d
BLAKE2b-256 8e45b41730e90aa9b35200b69d89d499e94a3fc5fa8fdfa179c1eea1afa11af3

See more details on using hashes here.

File details

Details for the file thinc-8.0.0a22-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.0a22-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 950.3 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.0a22-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6d682c0d94287bb180402298a7cba90f8e38aef6c6427495d9282ff91cd97858
MD5 fb966a73aaccf171305cda0a043aa0b6
BLAKE2b-256 49431258fafb5551f389efae48129c68162ff5e6a400f0e4b7a719d34df3a19b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a22-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 964.1 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.0a22-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b5fc462f0d800236ade654ec4084a822bed9c0c777c6e18f54fdd70bf5ea223b
MD5 718dc63d7734872d095240739ca3c59c
BLAKE2b-256 28fcc10c90b1eb07355a0776e6e4995690dc99e234025d9c3dd953dae060b3e1

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