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 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. Before you install Thinc and its dependencies, make sure that your pip, setuptools and wheel are up to date. For the most recent releases, pip 19.3 or newer is recommended.

pip install -U pip setuptools wheel
pip install thinc --pre

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.

⚠️ If you have installed PyTorch and you are using Python 3.7+, uninstall the package dataclasses with pip uninstall dataclasses, since it may have been installed by PyTorch and is incompatible with Python 3.7+.

📓 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
pip install -U pip setuptools wheel
pip install -r requirements.txt
pip install --no-build-isolation .

Alternatively, install in editable mode:

pip install -r requirements.txt
pip install --no-build-isolation --editable .

Or by setting PYTHONPATH:

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.13.tar.gz (175.1 kB view details)

Uploaded Source

Built Distributions

thinc-8.0.13-cp310-cp310-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.0.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (637.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.0.13-cp310-cp310-macosx_10_9_x86_64.whl (616.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-8.0.13-cp39-cp39-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (636.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.13-cp39-cp39-macosx_10_9_x86_64.whl (615.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thinc-8.0.13-cp38-cp38-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (636.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.13-cp38-cp38-macosx_10_9_x86_64.whl (609.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thinc-8.0.13-cp37-cp37m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.13-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.2 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

thinc-8.0.13-cp37-cp37m-macosx_10_9_x86_64.whl (601.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

thinc-8.0.13-cp36-cp36m-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.13-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.6 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

thinc-8.0.13-cp36-cp36m-macosx_10_9_x86_64.whl (602.9 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file thinc-8.0.13.tar.gz.

File metadata

  • Download URL: thinc-8.0.13.tar.gz
  • Upload date:
  • Size: 175.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13.tar.gz
Algorithm Hash digest
SHA256 47662a3ae33d445a77b6ea7b772444805c7bba8991f122e350daf72dedc8171a
MD5 73c5bdc135abc4ffbae5ab3d5940de64
BLAKE2b-256 1b12f1c2b13603b5e98aa47b87896a189832cc28aff46e8d959745901f01b148

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2b217059c9e126220b77e7d6c9da56912c4e1eb4e8a11af14f17752e198e88cc
MD5 34d0db2b55bd1beaf4b2dcd5449ef9e1
BLAKE2b-256 dbab28fb45ee64f790573aa834c7164184a2c66f9b6ed32ba01094ad6d22d0c1

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f520daf45b7f42a04363852df43be1b423ae42d9327709d74f6c3279b3f73778
MD5 8d3770bbeab591a86c9479142bc1f800
BLAKE2b-256 229cdc343d072e787abde7555aeaffee4bab0d420f751870814ea90dc8a095bf

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 616.5 kB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f818b9f012169a11beb3561c43dc52080588e50cf495733e492efab8b9b4135e
MD5 222c67af69a6fefcbd4e4c1bc62f9429
BLAKE2b-256 1c6c437ba91f3e1a6bef772c7b481176cca5a125428e0aa71b5f15267e7d6262

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b3ae088f60d3dfe6a88c6be37548aae40023e46a718cffe3e43953b4f0ffc340
MD5 5115092b52a2a7d0a7ee6052cf8ce06a
BLAKE2b-256 5238599fa9a918e9aa7aa27eeec1512ee0d6967746705cc5b74999b21699841a

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce322b66053819654d0444877154a08ed01cf5b45c6b3c9763e59b78af4f6039
MD5 5f06a16c1d12b6843a5bf60f769e5ed2
BLAKE2b-256 9ba549d6a11800892a0ed3b2c4ebca5e3a70eecbeb9ba6db608183143445373f

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 615.2 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 def8e96eddb5a098d07dcf8752266095e14a6cf5d056ff766e2cdc542eb63f02
MD5 74604ee9a64099da0411a12951151586
BLAKE2b-256 5a81b2494009a7e65ba865cb0bcbdd7bcc9079d1b2aac25ab1a6bcb3330cafbb

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ba576af211ad2b00af78ab3e24e689289b29af8a9e51619ad55fab86871d8652
MD5 26d9f01f58db9bef52a1daf8a064f515
BLAKE2b-256 8932f7d47bb433e812c1779c49084dcc3a967dd9e86996bda86dccb6068947fe

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b61f78f6f116d23438b034c3552804c9767c4165960b1d7e48f07b2e9a95afb0
MD5 76e720a4cf9d4c2bd5befd5329b2b49d
BLAKE2b-256 7e3833b849ed5aae326aabb32a6ff0241f276a86f71c4a747b16c3496b5bc4a4

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 609.3 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ffe0a4d74f2ba2819193a5d9179156256f44c69255d7ae286ce1861efcefbc64
MD5 28cf67ea2eb37f723924d9ebd6aa080f
BLAKE2b-256 8c5b9e3b38ea2d6b12a9fb752e5b86ef0388fdafb95d96625e64f80cdceb62c3

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 753f65e07860553551ed8806b934a74f26a4a50985d556ecd5c4ab50c29b3222
MD5 eb3f062c56bca89895f1d6a486aa59a8
BLAKE2b-256 657ac36466b644df4aef3e4d5a91969e86f0a9f85e29e8bcbe5c8d922b6574fe

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.13-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d52a5621e1784af5c64af4cfa9b2924358ca07aafd99014c57a736cf032e42f7
MD5 622a6c255d5dde680c9d697d780ce51e
BLAKE2b-256 bf495ff0590b2fb4739aad50ac64560f72dd6c182827e84798837d5dee358b40

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 601.8 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1f274bcaa781aaf1dba5eac7da7d88d9b0cb8c2fd7477647f0ca9d3221dfb958
MD5 4800b6ac0e786bd28aaf54759adc1ce0
BLAKE2b-256 12ba2193abd1bd12f3468b6e0d2fad7def8433084f7032e2143b51893effcfd9

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 27ea64843d6af0f3de8c788ec2a00598a1e5b4d57aadb52845fa42e95e4038c2
MD5 932dee078c7aabffc9c873ccf2f14f2f
BLAKE2b-256 a30bc3e33acdb109c9918bb29da58ae42e05e81ecf944d49cccbf91017b8ff6b

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.0.13-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a17d87469082b82c27b7d40dd86c793fc34c60f734209ee056cb02d7609f255b
MD5 c4db02b942b945773d0f1fd3e77024bb
BLAKE2b-256 ad8c2e31f56f463d6df7b0263c31ccc10c2999ea7965f53f6c5b19c74f276290

See more details on using hashes here.

File details

Details for the file thinc-8.0.13-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: thinc-8.0.13-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 602.9 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for thinc-8.0.13-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0f956c693d180209075703072fd226a24408cbe80eb67bd3b6eea407f61cb283
MD5 427c14956b0213d0b56c44d9735e1ea4
BLAKE2b-256 90e7d19a51b0d7679948153dfe48425c1d434909ce6b4628e99aad9bc6ab3a89

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