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.0a0

⚠️ 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.0a1.tar.gz (576.3 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.0a1-cp38-cp38-win_amd64.whl (942.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.0a1-cp38-cp38-manylinux1_x86_64.whl (971.6 kB view details)

Uploaded CPython 3.8

thinc-8.0.0a1-cp38-cp38-macosx_10_9_x86_64.whl (984.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.0a1-cp37-cp37m-win_amd64.whl (935.1 kB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.0a1-cp37-cp37m-manylinux1_x86_64.whl (976.0 kB view details)

Uploaded CPython 3.7m

thinc-8.0.0a1-cp37-cp37m-macosx_10_9_x86_64.whl (978.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.0a1-cp36-cp36m-win_amd64.whl (935.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.0a1-cp36-cp36m-manylinux1_x86_64.whl (976.9 kB view details)

Uploaded CPython 3.6m

thinc-8.0.0a1-cp36-cp36m-macosx_10_9_x86_64.whl (985.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.0a1.tar.gz
  • Upload date:
  • Size: 576.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1.tar.gz
Algorithm Hash digest
SHA256 c44563db199ae61d28fe282d07404f1fb6140f9d09be9a97718d82151b5968e0
MD5 a10e058e52a8c39a00b8c02f0f9664df
BLAKE2b-256 0282270c708accfc5594f5960aad79107c0213338dbdc8eedfac1210c8f4080c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 942.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5c844212c76eb302bea8f54d1cf562516cd51e7a599d47ed146a2dbdf73b7397
MD5 753183a92284235babd3c62c18dae625
BLAKE2b-256 410aa1c1d8b50d2a20ea3a2ebe3f61e23fdac37f9492fe85c15545f0ec8bf3a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 971.6 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6aea9ba220c4347a3873cdc26666cee29cd25bf277702e7d98a4ec67f709a92e
MD5 56a9a1ae7c59e060e8c81086e8182f9e
BLAKE2b-256 2a68190400ddb12baa7078471f315c0505dffb3f14f9234dbd6b1c02b47d9822

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 984.0 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dfbe95332970ba24c58275bfd377f45f873790cb5ccb4bbb014bd73d42e8ff46
MD5 cdd6e22a61768a19a79a0299837f7366
BLAKE2b-256 936c9fdc714d48162a14a2a6333f56813308f0bc72b6d56f4e5ae0f5323e53e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 935.1 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a221666d2c7843887f871b2d105498389acccc274f5cd9dc8ec77abd0506dbbf
MD5 a5ab93d18687b4d6545ee96dc547b72d
BLAKE2b-256 6bedc9225118563e3a9c44f9639722175e2a2b6881aacd52a477d7adc7194f25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 976.0 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 196658fbb22a7d4c89d72f8de8a7cae1a7acb4b5b13d4703e999a46c29431011
MD5 c5fd36f6ead3ad439eec4590cb13d3ec
BLAKE2b-256 3a3dafff0ca61bee1ee68fd1565e776a0d4631e94952bcd015e800ea87c22d67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 978.0 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 098f873839738cea156cb5f64f893bfae212f6bd269361c33d78e9b5feca0534
MD5 05e80466e046f67bc02da77ac956fb82
BLAKE2b-256 fda23a98501b55c10f00a9b790dbed4b006815e10148b09d7498fc0d96efe06d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 935.5 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 2bc7487f0772e30334d586b602b3359ccee2a58fc4b97305dacc43dcaca8e4b4
MD5 049ac8a255da63f2c46a18b32f1bf313
BLAKE2b-256 5a111c2fddcdfff1ca3046e67d0f970cd74647d2e52767b473ec3374b30d208a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 976.9 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1c0a3d10da09559ce64b7148eb86b1ba22e410e0bbfbc85bc567f2290f3dba74
MD5 cbef8d00f62146ade061d50869b0799e
BLAKE2b-256 0fca1eeb6d0daeac8c7075813cf3d13b8e5cea07eb69103bd168a4d177ed4e41

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.0a1-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 985.7 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for thinc-8.0.0a1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ee7156707b5939eaac290a4768149155c378c55d7833608d70df2c45e4ff8b4b
MD5 699ee36e94c1e44e97bceb6a5c370c1d
BLAKE2b-256 d48d0818b52971a2091db316eafcf96863d7f8af63f295c36198bdf3c659276b

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