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

This version

8.0.7

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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

thinc-8.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.0.7-cp39-cp39-macosx_10_9_x86_64.whl (603.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

thinc-8.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

thinc-8.0.7-cp38-cp38-macosx_10_9_x86_64.whl (597.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

thinc-8.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (620.0 kB view details)

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

thinc-8.0.7-cp37-cp37m-macosx_10_9_x86_64.whl (590.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

thinc-8.0.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (621.3 kB view details)

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

thinc-8.0.7-cp36-cp36m-macosx_10_9_x86_64.whl (591.7 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.0.7.tar.gz
  • Upload date:
  • Size: 166.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7.tar.gz
Algorithm Hash digest
SHA256 7c4382f22a5a3864b88cafe6e64f7a69f64b32147575b5f1e6f2211a8adb11f9
MD5 423b47c46424a7440f0f61ff03ba36a6
BLAKE2b-256 dc09ec156380f339942a576887fc07ba367080386d2e5166ef70883138da8f4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-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.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 003b0565b6089cd7976a81a2525e1d5ca976e04291a3d8f383f2879a45d52bce
MD5 2c0cedb2629c190697c93737fa3ef3b4
BLAKE2b-256 020608945a6ccdb840445ab7bab45c1d8e714e1c5fc15f38948f798125e48f12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8c592e4e844390de3b6c977bcdd1c8ee776a59fa6b5b74700cc4fa38075c83f
MD5 0a9319d7234037efe3ab87bbb05b004f
BLAKE2b-256 f5d9e926915b9fcd23fb515bd57651e7bba12d1fe6c6b407a4e8cf0b1b033b70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 603.6 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4cf10fbdafcd3c55c6954fbfc52997c188e73e89e961ef5789f96c02bc2e474a
MD5 1f1d9de1729ae26027329e9e2f9606f4
BLAKE2b-256 da01323e8c035f61d89f660f38c387568d7065b7836559fb4a6d34241027b72f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-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.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3f15f3108e2c53263332809384a95d0df5cdad55c5bcefb32edbd9d64c519b2c
MD5 e113af15d88c61104c766e9de6a4e8d0
BLAKE2b-256 9cafbe34aef28fbfab2aeb9af4db02d2df4cf1b089539cddd72d02971f1d3b9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 301bd09cf940e5a167460b750ac37c655c33652fb1c47eb2098f98a96952ed02
MD5 1f73517e0740d6588773c71f50b9339b
BLAKE2b-256 545727d1fecc39c02ea4f78b89d8bb1ce76d5946d4e6b6c75d64b7b759c7aa25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 597.5 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 490aaefa28a046c6c0515441d14de782f6bbb73bc04b02446a2909c81e501150
MD5 b73dd44b37cc57b94715f82fe40eeb43
BLAKE2b-256 a1fe905a9aa663926cd94f7363303fce31d1ab5aa81d648976ac59ceaac82bfa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-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.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 8258360cfb420a693fd4baedbbb2cae9cf848a435d45879b71a96a0ce6cbe81b
MD5 969052fdfd236eb69907f7276e0fca83
BLAKE2b-256 0afbac9ed9564707d15b94d364e1382101cf9e17b6a27f85c0564ee3166ba459

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00770eabfc987f7ea3373680a1ea2598ae6ad78950bc2958be3bb37a8e6ca774
MD5 f021fd1637a38e791bf656d51ac2a8fc
BLAKE2b-256 7a6ebd2da3d71ab2d175248949ac106fee09ae13bfaca39002eabdbd908b7440

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 590.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d540c1826552ce0ee17cff50ed36919a531a1b655b39d4f15b2b4c5e8c2c7852
MD5 513f8252bcd4111e4f515fce832f02c9
BLAKE2b-256 10d00003493d76bdd11a1fe4fb60c52667a7d89204b97da2b1c5c165c15bf776

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-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.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1922081b475177b551dcc586ab7d245b3cad8e49d13133c6f524eae30eb0a111
MD5 0943b3291a3cd10f256a720989780ba4
BLAKE2b-256 cb3a28298141b8910c13436fc1760b19056df9f62b49a16a13df8618a373c00e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.0.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 38bd40a1674683459c86af9851206ed01ee4e88342aaf213b89ab2dee446187d
MD5 410f4783837a4ab66eae61ca66408dec
BLAKE2b-256 9a7ebad899a68e619c3879a6a90c30d11174b1280f83a3a3b42d2e5cec7f20b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.0.7-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 591.7 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for thinc-8.0.7-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b1265ba0f1ef6e085b6e0a2fb031e25cb55fa3e26d109e6b0cd9a424c76e98f5
MD5 69228e57d93124a3cc46e31bc4d01176
BLAKE2b-256 367792da0ea725b9c072abcf3c58bb4c81d2cb25dd8794bba638cc90300bae4b

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