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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

thinc-8.0.0a23-cp38-cp38-win_amd64.whl (921.3 kB view details)

Uploaded CPython 3.8Windows x86-64

thinc-8.0.0a23-cp38-cp38-manylinux1_x86_64.whl (939.7 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a23-cp38-cp38-macosx_10_9_x86_64.whl (961.1 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

thinc-8.0.0a23-cp37-cp37m-win_amd64.whl (913.9 kB view details)

Uploaded CPython 3.7mWindows x86-64

thinc-8.0.0a23-cp37-cp37m-manylinux1_x86_64.whl (948.4 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a23-cp37-cp37m-macosx_10_9_x86_64.whl (957.2 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

thinc-8.0.0a23-cp36-cp36m-win_amd64.whl (914.1 kB view details)

Uploaded CPython 3.6mWindows x86-64

thinc-8.0.0a23-cp36-cp36m-manylinux1_x86_64.whl (950.8 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a23-cp36-cp36m-macosx_10_9_x86_64.whl (964.6 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a23.tar.gz
  • Upload date:
  • Size: 578.5 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.0a23.tar.gz
Algorithm Hash digest
SHA256 9171aa3d2333a1bd1e15a694780fbb8963eab8d6c1e345850917fef87e269f93
MD5 22ef83e66fa86763abac98235259842d
BLAKE2b-256 66369b9efe85a8073fffc8d7fe484281bb12ae30376909363267b9f44523ad9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a23-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 921.3 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.0a23-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5f7f3512e895baabc99a12d74c30d64dfe39a1b8b6eb5515dbf75080a2ec05c8
MD5 c71bdf17ea74d2b111385d054e6a3364
BLAKE2b-256 52a55a00fad6a54f66ca73e1e40cab53c9c49fe9472b8bb7d09604e5558f24d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a23-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 939.7 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.0a23-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9e69256791d0619263c7acacfd144ad7b3723c29e150117be380823667f05ef2
MD5 eca34bfb493e52b6afb34ce456e71550
BLAKE2b-256 79dc2f32fd3c27b47814f96e3f7f5dc4207818d07608b1356450fde5575a2a05

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a23-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 eeed4a16ad21a417d34576b36be248aec69038594865d4ae624b3ec95350cb80
MD5 e6bda6cd6da335fa84c8ae3307004d72
BLAKE2b-256 bec739156ef60a8c826c852ae474513c6a7194a1ef8f29f656f84f9192158c5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a23-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 913.9 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.0a23-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 e835713c5d69c4718cc3723a36ca5865edcc3b5c8bdfccb11972eeceb2a43522
MD5 671fecec9000d9c67e03b6b0769cc76f
BLAKE2b-256 b90d03ca3ae0fb6186a4cef5ddebdba0b534d7f4ee4169144281bebd28120766

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a23-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 948.4 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.0a23-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8e942beefc28212dcb2502d6a5c89acc94ed8a7d5b690a7ea42c6e5b145f2ab7
MD5 3be41e865a6ce8f1bbd80b72d6d59395
BLAKE2b-256 50a79d8d24305622ee837a399b0dede8fefbf729528bc03c36eedbc7c16c8089

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a23-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 79fb55794df2c3e193977b09c0cf2c79b1aa21dcd1599970c7e8a43297af097e
MD5 0b0c81d28a7521376e8cf7b26f5711d3
BLAKE2b-256 e464cc369f8eb4d3747bbac2d2ed6b12de328486281d8316782845a4fd9c8b2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a23-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 914.1 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.0a23-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 4d0b7edb13793678421815023c76f1191cd94a7dd3bedadac7c827f25f3b3891
MD5 2c86760784936fb881961592731fbfeb
BLAKE2b-256 b0a8c8251f67ee52d51ef0772394494dea7f55ecf7b64713d48f15a44c4abfd8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a23-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 950.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.0a23-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e17c6765e508e4eeb26c526b5a0167676bc9ca4ac38219eaba85e52bf40d184c
MD5 45cca30ab518a6dc4fdb0fcd43ec0150
BLAKE2b-256 2467c1800d107f8d7ceb4d9e80ef7bff46c736feb70f579f6ed70962852d4f54

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for thinc-8.0.0a23-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4dd8ea40af285cfa66cc0e13604b27e679cb7c751d45dce54dbccfa65eab4482
MD5 021db4290821e590a98428ef6478c95c
BLAKE2b-256 f818c1fe4ac774e66dbc482eacd282985d699ee1e89918dcf89b412e0e5e8624

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page