Library / SDK
explosion/thinc avatar
explosion/thinc

Thinc: a functional composition layer for models you already train elsewhere

🔮 A refreshing functional take on deep learning, compatible with your favorite libraries

2,890 stars295 forksPythonMIT

At a glance

What is it?
Thinc is a lightweight Python library for composing neural network models from layers that may live in PyTorch, TensorFlow or MXNet, with a config system and an optional mypy plugin. It is aimed at people who want to describe model graphs as function composition rather than class inheritance, and it is the layer spaCy is built on.
Who is it for?
Adopt Thinc if you are building spaCy-style pipelines or want a typed, config-driven way to assemble layers that already exist in PyTorch, TensorFlow or MXNet. Do not adopt it as a replacement for those frameworks: it has no autodiff engine of its own and no pretrained model zoo.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 173 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The gap Thinc fills between model code and model plumbing

Most deep learning projects end up with two kinds of code: the layers that do the maths, and the wiring that decides which layer feeds which, what hyperparameters get passed, and how the whole thing is serialised. Thinc targets the second kind. The README describes it as a lightweight deep learning library offering an elegant, type-checked, functional-programming API for composing models, with support for layers defined in other frameworks such as PyTorch, TensorFlow and MXNet. The intended user is someone who already has layers they trust and does not want to rewrite them to fit a new framework's class hierarchy. Thinc is also the library underneath spaCy, and the README notes that previous versions have been running in production in thousands of companies via spaCy and Prodigy. That is the honest framing of its maturity: its track record comes from being an internal dependency of a widely deployed NLP toolchain, not from being a general-purpose training framework people reach for on its own.

Composition instead of inheritance, and what that changes in practice

The core design choice is stated plainly in the feature list: a concise functional-programming approach to model definition, using composition rather than inheritance. In a subclassing framework you define a class, override a forward method, and register submodules as attributes. In Thinc you build a model by chaining and combining layer objects, and the README mentions optional custom infix notation via operator overloading as a way to write that composition. The practical consequence is that a model becomes a value you can pass around, wrap, and recombine, rather than a type you must extend. The second half of the mechanism is the config system, described as integrated, for describing trees of objects and hyperparameters. That means the structure of a network and the values fed into it can be expressed in a config file rather than in Python control flow, and the README's example notebooks include using config files and registering custom functions alongside wrapping PyTorch, TensorFlow and MXNet models. Type checking ties the two together: Thinc ships custom types and a mypy plugin, so the shapes and layer signatures in a composed model can be checked statically. The README also notes that type validation was re-enabled in the v8.3.12 release, which is worth knowing if you pin an older 8.3.x patch.

Installing Thinc and what the README actually tells you to run

The quickstart is two commands. First bring the packaging tools up to date, then install the library:

pip install -U pip setuptools wheel pip install thinc

The README states that Thinc runs on Linux, macOS and Windows, that binary wheels are published to PyPI, and that pip 19.3 or newer is recommended for the most recent releases. Optional dependencies for different backends and GPU support are not listed inline; the README points to an extended installation page at thinc.ai/docs/install for those. There is also a separate page for setting up static type checking, which is where the mypy plugin configuration lives. One concrete warning is given in the README and is easy to miss: if you have installed PyTorch and you are using Python 3.7 or later, uninstall the package dataclasses with pip uninstall dataclasses, because PyTorch may have installed it and it is incompatible with Python 3.7+. The README does not reproduce the config file syntax or the mypy settings in the text, so those have to come from the documentation site or the example notebooks.

Where Thinc stops being the right tool

Thinc is a composition layer, not a training engine. The README lists support for layers defined in PyTorch, TensorFlow and MXNet, and describes Thinc as usable as an interface layer, a standalone toolkit, or a flexible way to develop new models. Nothing in the supplied material claims an autodiff implementation, a distributed training stack, or a model zoo. If your problem is training a large transformer from scratch, Thinc is not the thing doing the work; you would be writing the training loop in your backend and using Thinc for the surrounding wiring, which may be more indirection than the task needs. The same applies to teams with no existing framework investment: adopting Thinc means adopting a second abstraction on top of whichever backend you pick, and the README's own framing (compose, configure and deploy custom models built with their favorite framework) assumes that first choice has already been made. There is also a versioning consideration. The default branch is v8.3.x and the recent releases are patch-level bug fixes, validation changes and a confection v1 update that the release notes tie to full Pydantic v2 support. That is a maintenance cadence, not a signal about capability, but it does mean config-related behaviour can shift between patch versions.

Thinc against plain PyTorch or Keras

The nearest alternative is simply not using Thinc: define your model as a torch.nn.Module or a Keras model and keep the wiring in Python. The difference is where the structure lives. In PyTorch, the architecture is expressed as class definitions and attribute assignment, and hyperparameters are usually passed as constructor arguments or read from your own config handling. Thinc moves the structure into a config tree and the composition into chained layer objects, and adds static type checking over the result. If you value being able to diff a config file to see what changed between two model versions, or you want mypy to catch a shape mismatch before runtime, Thinc's approach buys something PyTorch alone does not give you. If you value a single well-documented framework with a large body of tutorials and no extra abstraction to learn, plain PyTorch wins on that axis. Keras sits closer to Thinc in spirit, since it also separates model definition from training, but it is tied to TensorFlow's ecosystem rather than being backend-agnostic, and it does not offer the same framework-wrapping story for PyTorch and MXNet layers.

Maintenance, licence and what to check before you depend on it

Thinc is MIT licensed, which is permissive and places few obligations on how you redistribute it, though the usual caveat applies that this is a description of the licence identifier and not legal advice for your situation. Maintenance is active: the repository is not archived, the most recent push is dated 2026-03-27, and the three most recent releases (v8.3.11, v8.3.12, v8.3.13) landed within days of each other in March 2026. Those releases are described as bug fixes, validation improvements, re-enabled type validation, and support for confection v1 enabling full Pydantic v2 support. The upgrade cost is therefore mostly in the config and validation layer rather than in the maths: if you rely on the config system, a Pydantic major-version change underneath it is the kind of thing that can surface as validation errors on previously accepted configs. Pin your Thinc version, read the release notes for each 8.3.x bump before moving, and check that your backend wrappers still behave after the upgrade. The README's own advice to keep pip, setuptools and wheel current is the other routine maintenance item.

Who should pick this up, and what to verify first

Thinc is for engineers who already have layers in PyTorch, TensorFlow or MXNet and want a typed, config-driven way to assemble them, and for anyone extending or debugging a spaCy pipeline who needs to understand the layer beneath it. It is not for people looking for a batteries-included training framework, and it is not for projects where adding a composition abstraction over an existing one would cost more in learning time than it saves in structure. The first thing to verify is the wrapper behaviour for your specific backend at the Thinc version you intend to pin, since that is where the README's promises about PyTorch, TensorFlow and MXNet support become concrete. The second is the mypy plugin: set it up as the installation docs describe and confirm your composed model actually type-checks, because the type system is one of the main reasons to choose Thinc over writing the same wiring by hand. The intro_to_thinc notebook covers composing and training on MNIST, config files, registering custom functions and wrapping all three backends, which makes it the cheapest way to test those assumptions before you commit a real project to the library.

Editorial conclusion

Adopt Thinc if you are building spaCy-style pipelines or want a typed, config-driven way to assemble layers that already exist in PyTorch, TensorFlow or MXNet. Do not adopt it as a replacement for those frameworks: it has no autodiff engine of its own and no pretrained model zoo. Before committing, install it, run the intro_to_thinc notebook, and confirm that your backend's layer wrappers behave as you expect under the version of Thinc you pin.

Official sources

  1. explosion/thinc on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Community notes

Community notes