Thinc

A lightweight, type-checked functional deep learning library that wraps PyTorch, TensorFlow, and MXNet

Library
PyPI
v9.1.1
2,890stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
59/100Fair
Development Activity8
Maintenance44
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture82
Code Quality78
Innovation75
Learning Curve65

Thinc is a lightweight deep learning library from the makers of spaCy and Prodigy, built around a functional-programming API for composing neural network models rather than the class-inheritance style used by most frameworks. Instead of subclassing a base module, you compose small, typed layer functions together with combinators, and Thinc handles parameter management, gradients, and serialization underneath.

Thinc can be used as a standalone toolkit for building and training models from scratch, or as an interface layer that wraps and orchestrates layers from PyTorch, TensorFlow, and MXNet inside a single computation graph. It ships an integrated configuration system for describing trees of objects and hyperparameters from config files, custom static types with a mypy plugin, and pluggable backends for numpy and cupy so the same model code runs on CPU or GPU.

What You Get

  • A functional Model abstraction where every layer is a typed, composable function rather than a subclassed module
  • Wrapper layers (PyTorchWrapper, TensorFlowWrapper, MXNetWrapper) for embedding models from other frameworks in a Thinc graph
  • An integrated config system (built on Confection) for describing model architectures, hyperparameters, and registered functions in .cfg files
  • A large built-in layers library covering linear, embedding, normalization, attention, and recurrent building blocks
  • Pluggable backends (numpy_ops, cupy) so the same model definitions run on CPU or GPU without code changes
  • Static type checking support via custom generic types and a bundled mypy plugin

Common Use Cases

  • Powering spaCy’s and Prodigy’s internal NLP model components in production
  • Wrapping an existing PyTorch or TensorFlow model so it can be trained and served through Thinc’s config-driven pipeline
  • Building small, fully custom neural architectures (e.g. CNN taggers) using functional composition instead of framework boilerplate
  • Describing reproducible experiment configurations and hyperparameter trees via Thinc’s config/registry system

Under The Hood

Architecture: Thinc centers on the Model class (thinc/model.py), a generic container for parameters, gradients, and a forward function; layers in thinc/layers/ are plain functions returning Model instances, composed via combinators (chain, concatenate, clone) rather than subclassing, with wrapper shims in thinc/shims/ bridging PyTorch/TensorFlow/MXNet models into the same graph.

Tech Stack: Python core with Cython extensions (thinc/backends/cblas, numpy_ops, linalg) for performance-critical linear algebra, numpy/cupy as pluggable CPU/GPU backends, and the Confection library powering the config/registry system.

Code Quality: An extensive test suite lives in thinc/tests covering config parsing, serialization, optimizers, schedules, and layer indexing; the project enforces black formatting, flake8 linting, and mypy type checking, and aims for full test coverage per its README.

API Design: The functional composition API (chain/concatenate/clone) keeps model definitions concise and strongly typed, though the framework-wrapping concepts and config/registry system add a learning curve for newcomers accustomed to standard subclass-based frameworks like plain PyTorch.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search