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

This version

9.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thinc-9.1.0.tar.gz (191.9 kB view details)

Uploaded Source

Built Distributions

thinc-9.1.0-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

thinc-9.1.0-cp312-cp312-musllinux_1_2_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

thinc-9.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

thinc-9.1.0-cp312-cp312-macosx_10_9_x86_64.whl (827.9 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

thinc-9.1.0-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

thinc-9.1.0-cp311-cp311-musllinux_1_2_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

thinc-9.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

thinc-9.1.0-cp311-cp311-macosx_10_9_x86_64.whl (849.9 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

thinc-9.1.0-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

thinc-9.1.0-cp310-cp310-musllinux_1_2_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

thinc-9.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

thinc-9.1.0-cp310-cp310-macosx_10_9_x86_64.whl (853.1 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

thinc-9.1.0-cp39-cp39-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

thinc-9.1.0-cp39-cp39-musllinux_1_2_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

thinc-9.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

thinc-9.1.0-cp39-cp39-macosx_10_9_x86_64.whl (859.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: thinc-9.1.0.tar.gz
  • Upload date:
  • Size: 191.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for thinc-9.1.0.tar.gz
Algorithm Hash digest
SHA256 d5bd57b7b1745804ca305256e8283aaab3ee5b9701925fa6539587a275792bc5
MD5 95a4b8416a86df88ffedbda8d7988c1b
BLAKE2b-256 06a52650bc86778d0c95b4a3b5f165039a8e06c39cabbd9d948271cd69e915da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-9.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for thinc-9.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 392c34184634a1ad94fefc5499629f7c2d792076a11680a3d90f5460f4d07db4
MD5 6f245c9d7f55297d57310d4fc65c8c0d
BLAKE2b-256 bd4431fc654ead121e68cb659a435d6a73f33dc103e7a6387b61a77b35d9119b

See more details on using hashes here.

File details

Details for the file thinc-9.1.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-9.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 61fd4575ddeb883964e3587a85a9c416445b8ee2200e5050bebf366d2540fd05
MD5 16c778783dafc36cbfad3a1c99a56a56
BLAKE2b-256 75b71f5566d7b26b2afda7f3cfa297a34a28d23321f05641e8c7f979ff82f175

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1625a6359416ba6a6ae3fc20376ae106695aa6ab4d43f76dab847a1847d95bb6
MD5 78f57673ea836d499811e0f85b67958f
BLAKE2b-256 9b08c41e7997481b674a367003fed2f3123d0c018f3b6f0cf13de232b2aa0758

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 94ede71f27f09d2657b5e98872f9e1ff873b4b73f520e3bb5adf1f5f52d77f42
MD5 974b3222647e1d54680a813e963dc0eb
BLAKE2b-256 f3f0b3204c167ab77512d9913b5915324c494b599bfada9ebf7800e7fdacae7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-9.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for thinc-9.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 17e69b8ab5ab806f80d75141d1dc510475aec1847a2cc61dd74e6cf53a1bb33a
MD5 0fa74ff3fd21c5475f1eb0d2a09a59bc
BLAKE2b-256 b08f3bec3b79696bb65dac96f2994f0976e227e8cc3557760bbdd9c794833f46

See more details on using hashes here.

File details

Details for the file thinc-9.1.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-9.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5a19b196268ab5985165d61011c1fde2629712c19143b8d83b9f57f8e148fad7
MD5 f14819d2c77e4ac638368ba4acecf726
BLAKE2b-256 eea20dcc4508d95a1cae3885eb73a9341519d6411e223608a085663236cf3511

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 292788fb917fc1840708b4c664744d8d26cb3dd270d5630a11f32aea7cd0711d
MD5 cd00fc6004da3dd61ab9828c28f40685
BLAKE2b-256 480587fa627ebe2bb51aab297dd99717771619bef28d4374790b64c04b273db6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 af4bf94473d55da28129d4ac825f85acd78cde13c7de9e08286e5e25d4443e37
MD5 fec91833896ee7ca86a003acb92b1b05
BLAKE2b-256 fce9f96d1f37b73414adae4215002e3d65a51cbc27d32f3a9e18de67d73faa3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-9.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for thinc-9.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 41526cb5db3b5612c6db25bd564f44d47ea5906aea721fb3ab28140d2b9a4c16
MD5 a80fba8ff9c055113505aab0b0d86965
BLAKE2b-256 66b6eaa52bc6ba7298f8645859aa5c935562fd5297a811ea8d4f482e9eef3ba3

See more details on using hashes here.

File details

Details for the file thinc-9.1.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-9.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f2b56fe926ae4974ae9666cc9401822ba8eae54d59554c1dbaab4d6ed8e7390d
MD5 3434ad1df3ccff9afc323edc406c1247
BLAKE2b-256 fdd5e6883928f158f20fa9d4a507cce3e5381690fec9579d13d091de71ef58f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4cc99683185e960192e2afc7e04380961d5cd1c2d2869726e27f3272f242a198
MD5 eac5025d3a9723d46444055d799dee43
BLAKE2b-256 330d2cc29d4e344b801542c85601beec5c93ea21ad07ee0eab09278c3967181f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 062343db8965d14266385edc0d4b1e521eec90d651e394cf3bc1f35d981ebcae
MD5 0478944d0ec134194156cdd00c3c0ddf
BLAKE2b-256 6c4a5d6b5c525ff8f66e9b4123abe874fb03a313d66ffb48a175f87cf8cba09b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thinc-9.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for thinc-9.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c9483370e74e45ae206b8c833c63a5b56711b2f570aacba1b097d05def925cdc
MD5 91fc9ab4a067bf76c409ea273d84dd14
BLAKE2b-256 c48ff7e2c89f8feeb6213076a4c7c41a60cc34da9d8049614c2d09f52b9fea53

See more details on using hashes here.

File details

Details for the file thinc-9.1.0-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for thinc-9.1.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1490a0246a7e9b4e5178d494d74c5b111cab118696745afd80418caf87fb13f6
MD5 9dc250d04befebd9d0462523a8683fce
BLAKE2b-256 5c78b5f8af9d3170b307f241e5bb589a1222995f007c73ca4f957fcbe9716718

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c1aabf2631253c0b3c6b7668b949393e6aeb3e82af1be98ca07b57f9fb602812
MD5 e0a706694cd62cac5c3aafe9e13ef109
BLAKE2b-256 dd3c7a1794ff700b9ede11b5edf54a67228fcfae701a6321f90a1b9d3e75cfe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thinc-9.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fe0b7b8984e2c1672d0e02fe893161ed529e57d2016b9bdb8e22097544f65069
MD5 c9c36736a853f748c5930f52bbd98fc2
BLAKE2b-256 d114d9a069284681c0013fb9aefc0d58c8f746ea63ed405d6be1c9c8c4132ebd

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