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 and Prodigy

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.

tests 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

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

Documentation Description
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.2.5.tar.gz (193.0 kB view details)

Uploaded Source

Built Distributions

thinc-8.2.5-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12 Windows x86-64

thinc-8.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (865.0 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

thinc-8.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (818.8 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

thinc-8.2.5-cp312-cp312-macosx_11_0_arm64.whl (760.6 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

thinc-8.2.5-cp312-cp312-macosx_10_9_x86_64.whl (824.1 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

thinc-8.2.5-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11 Windows x86-64

thinc-8.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (920.2 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

thinc-8.2.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (868.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

thinc-8.2.5-cp311-cp311-macosx_11_0_arm64.whl (773.9 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

thinc-8.2.5-cp311-cp311-macosx_10_9_x86_64.whl (839.1 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

thinc-8.2.5-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-8.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (922.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-8.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (868.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

thinc-8.2.5-cp310-cp310-macosx_11_0_arm64.whl (779.0 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

thinc-8.2.5-cp310-cp310-macosx_10_9_x86_64.whl (843.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-8.2.5-cp39-cp39-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-8.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (937.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-8.2.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (882.1 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

thinc-8.2.5-cp39-cp39-macosx_11_0_arm64.whl (780.5 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

thinc-8.2.5-cp39-cp39-macosx_10_9_x86_64.whl (847.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-8.2.5.tar.gz
  • Upload date:
  • Size: 193.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for thinc-8.2.5.tar.gz
Algorithm Hash digest
SHA256 c2963791c934cc7fbd8f9b942d571cac79892ad11630bfca690a868c32752b75
MD5 31be9b30c71a65470746705d3ab417c9
BLAKE2b-256 3b2a0e2e961e6152bedecca70e6833f6e827ee621efcee7496643242b506d54f

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: thinc-8.2.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for thinc-8.2.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c5f750ea2dd32ca6d46947025dacfc0f6037340c4e5f7adb9af84c75f65aa7d8
MD5 61a98d1b35c464a494de9a180244675e
BLAKE2b-256 cd26306b8bedb678c52464ed00e576edf9d365fce0bcae597a333bdad9fb5d67

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87e729f33c76ec6df9b375989743252ab880d79f3a2b4175169b21dece90f102
MD5 524114599bb9b6db7484d232a8c212bf
BLAKE2b-256 d7fac96b01e46e5962d02de1206e497fda2902aef2b8ffb2926d66d5f0159040

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e8a8f2f249f2be9a5ce2a81a6efe7503b68be7b57e47ad54ab28204e1f0c723b
MD5 b97a859446df3052c65a791a5aa90532
BLAKE2b-256 82ceaaff1f39bcc1e9a97bec5f3d20aa771c005a9faff3944fc56c7492c24466

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e299d4dc41107385d6d14d8604a060825798a031cabe2b894b22f9d75d9eaad
MD5 3cedaac2945b17071c65682d45116f54
BLAKE2b-256 66a630ed1edb2adab585b5f7d5d99e89b5be3014dcbf3f4e263997b2c2426681

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9fc26697e2358c71a5fe243d52e98ae67ee1a3b314eead5031845b6d1c0d121c
MD5 57a52ec140724da247b31155782217af
BLAKE2b-256 a49dd2ed3aef9bb75ab86c521bde58f897db6a572c9fd639448173b516269a69

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: thinc-8.2.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for thinc-8.2.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8ef5d46d62e31f2450224ab22391a606cf427b13e20cfc570f70422e2f333872
MD5 644eaf5db85ec65cdcbfba75ad6405d2
BLAKE2b-256 5e0e5e7b24e046e0725eafc37ded0cd9bfaf789efb894101a7aca8a73dba81de

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8901b30db1071ea8d5e4437429c8632535bf5ed87938ce3bb5057bed9f15aed8
MD5 6d388f37b195a79ecbfc44bc1f31076d
BLAKE2b-256 1a19cd73e3b5f22d5d9399f6f2931ab0fb985415f34030dcfead070181866761

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 34db8a023b9f70645fdf06c510584ba6d8b97ec53c1e094f42d95652bf8c875f
MD5 7c612661508a2cd2913e21ddcd62b1d2
BLAKE2b-256 344706810a1bd9d3287076ba17299abec82c8c643563661b1af9b1d5d9aeab38

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b166d1a22003ee03bc236370fff2884744c1fb758a6209a2512d305773d07d7
MD5 5f4f579b161ed4039319c6214dc38c80
BLAKE2b-256 e9eb753a85875fb0261c83ca87a1a36d41346bde662c3a029ace9d68fe32bc5b

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a75c0de3340afed594beda293661de145f3842873df56d9989bc338148f13fab
MD5 0e4382d10f8b51d91d446417d4459c2c
BLAKE2b-256 76378acfeba6bb25b08c2a33bfae5301a5df4dc164d2d17040bebbcf66d783a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.2.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for thinc-8.2.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 399260197ef3f8d9600315fc5b5a1d5940400fceb0361de642e9fe3506d82385
MD5 2daa7c2b0b4bd215a13fc246dfe82e27
BLAKE2b-256 f63efb96407db92a15b5c0feb0deb930c4c223bdb772e04b51b9798a86059a26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54bac2ba23b208fdaf267cd6113d26a5ecbb3b0e0c6015dff784ae6a9c5e78ca
MD5 70129cbd08b51ce55b81cfe8b5939dea
BLAKE2b-256 d7b5ad029dc7346381922b7fd655b3fc39009cf675766345d8e13f9f8282bde8

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0933adbd3e65e30d3bef903e77a368bc8a41bed34b0d18df6d4fc0536908e21f
MD5 640666a7a8c9d3fc41310d02fdb971a6
BLAKE2b-256 c0767dcce5cd2b5a9fe92b76767d688f17fe459543c13893e588545db3c0dc85

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d80f1e497971c9fa0938f5cc8fe607bbe87356b405fb7bbc3ff9f32fb4eed3bb
MD5 f9ee25dae4c90317c21d642195b027b4
BLAKE2b-256 e57647e94af32943bd92d7cda4e92d185331a89116a0bf87123cc71796f21a00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.2.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc267f6aad80a681a85f50383afe91da9e2bec56fefdda86bfa2e4f529bef191
MD5 940e6568f43168138dd72b9015da0681
BLAKE2b-256 a2761994abe2bf5cbe5f68231fd2c177e384b19bed86268d56c1b6b2dc19e203

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-8.2.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.9

File hashes

Hashes for thinc-8.2.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 df2138cf379061017ecb8bf609a8857e7904709ef0a9a2252783c16f67a2b749
MD5 564b056310d9997cc4357e60f31ff5ad
BLAKE2b-256 642f3f9456b18d32f5d22fe1bfe036f9ddab9880463234b5b17940a7b79983f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b884e56eaeb9e5c7bfeb1c8810a3cbad19a599b33b9f3152b90b67f468471ac
MD5 d3c79caafe80b603280f70064793b3b8
BLAKE2b-256 5a19d03443aea8aba65a6f882ebcade9a8d486722f716be1d02e9132165fc139

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cdc27da534807a2addd1c3d2a3d19f99e3eb67fdbce81c21f4e4c8bfa94ac15b
MD5 4348b401e62fa12483797d941f42dcc1
BLAKE2b-256 13e98a915d106e6a255aca57f3573e7807eb1faafac29f4aeea2b4c14a6dc833

See more details on using hashes here.

File details

Details for the file thinc-8.2.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for thinc-8.2.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c78fb218273894168d1ca2dd3a20f28dba5a7fa698c4f2a2fc425eda2086cfc
MD5 f2e2c1ff01d3b59a25e3d85d3769d3b0
BLAKE2b-256 f0b944994ada2968523788b1bc9a7d424ea52a4685adc85f5dfff05b0dc1c8cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-8.2.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bb97e2f699a3df16112ef5460cbfb0c9189a5fbc0e76bcf170ed7d995bdce367
MD5 5ce72020ec3f8b16726bf1b20a0c5657
BLAKE2b-256 66d3bcaec5ef068f81f8c38ba31bbc9947086e44c24bdc86fca2c7cba76eabf7

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