explosion/thinc

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

What it solves

Building deep learning models often means choosing one framework — PyTorch, TensorFlow, or MXNet — and sticking with it. Thinc solves the problem of mixing and matching layers from different frameworks by providing a lightweight, functional way to compose models. It lets you define, configure, and deploy custom models that can wrap layers from any of those frameworks, so you don't have to commit to a single ecosystem.

How it works

Thinc uses a functional-programming style: models are built by composing small, reusable pieces (called "layers") rather than by subclassing a base class. Each model is an instance of a Model class, and you can chain layers together using simple function calls or optional operator overloading. Thinc includes a type system that works with mypy to check your model definitions at compile time, catching shape or dtype errors early. It also has an integrated config system that lets you describe trees of objects and hyperparameters in a declarative way (similar to YAML or config files) and register custom functions. To use external frameworks, Thinc provides "shims" — interfaces that wrap PyTorch, TensorFlow, or MXNet models so they can be plugged into a Thinc network. Backends (NumPy or CuPy for GPU) are swappable, and optimizers (SGD, Adam, RAdam) and learning rate schedules are included.

Who it’s for

Thinc is aimed at developers and researchers who want to build deep learning models with flexibility and type safety. It's especially useful if you already use spaCy or Prodigy (both built on Thinc) and want to extend or customize models. It also suits teams that need to combine components from multiple machine learning frameworks in one pipeline.

Highlights

  • Type-checked model definitions — use custom types and a mypy plugin to catch errors before runtime.
  • Framework interoperability — wrap PyTorch, TensorFlow, and MXNet layers directly in your Thinc network.
  • Functional composition — build models by combining small, reusable layers, with optional operator overloading for concise notation.
  • Integrated config system — describe object trees and hyperparameters in config files, with a registry for custom functions.
  • Extensible backends — switch between NumPy (CPU) and CuPy (GPU) transparently.
  • Proven in production — quietly powers spaCy and Prodigy in thousands of companies.

Related

  • Project
  • Project
  • Project
  • Project