freshcrate
Home > RAG & Memory > thinc

thinc

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

Description

<a href="https://explosion.ai"><img src="https://explosion.ai/assets/img/logo.svg" width="125" height="125" align="right" /></a> # Thinc: A refreshing functional take on deep learning, compatible with your favorite libraries ### From the makers of [spaCy](https://spacy.io) and [Prodigy](https://prodi.gy) [Thinc](https://thinc.ai) 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](https://spacy.io) and [Prodigy](https://prodi.gy). We wrote the new version to let users **compose, configure and deploy custom models** built with their favorite framework. [![tests](https://github.com/explosion/thinc/actions/workflows/tests.yml/badge.svg)](https://github.com/explosion/thinc/actions/workflows/tests.yml) [![Current Release Version](https://img.shields.io/github/v/release/explosion/thinc.svg?include_prereleases&sort=semver&style=flat-square&logo=github)](https://github.com/explosion/thinc/releases) [![PyPi Version](https://img.shields.io/pypi/v/thinc.svg?include_prereleases&sort=semver&style=flat-square&logo=pypi&logoColor=white)](https://pypi.python.org/pypi/thinc) [![conda Version](https://img.shields.io/conda/vn/conda-forge/thinc.svg?style=flat-square&logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/thinc) [![Python wheels](https://img.shields.io/badge/wheels-%E2%9C%93-4c1.svg?longCache=true&style=flat-square&logo=python&logoColor=white)](https://github.com/explosion/wheelwright/releases) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/ambv/black) [![Open demo in Colab][colab]][intro_to_thinc_colab] ## πŸ”₯ Features - **Type-check** your model definitions with custom types and [`mypy`](https://mypy.readthedocs.io/en/latest/) 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 &rarr;](https://thinc.ai/docs)** ## πŸš€ 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](https://pypi.python.org/pypi/thinc). 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. ```bash pip install -U pip setuptools wheel pip install thinc ``` See the [extended installation docs](https://thinc.ai/docs/install#extended) for details on optional dependencies for different backends and GPU. You might also want to [set up static type checking](https://thinc.ai/docs/install#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`](examples) directory and [usage documentation](https://thinc.ai/docs) for more examples. Most examples are Jupyter notebooks – to launch them on [Google Colab](https://colab.research.google.com) (with GPU support!) click on the button next to the notebook name. | Notebook | Description | | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`intro_to_thinc`][intro_to_thinc]<br />[![Open in Colab][colab]][intro_to_thinc_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`][transformers_tagger_bert]<br />[![Open in Colab][colab]][transformers_tagger_bert_colab] | How to use Thinc, `transformers` and PyTorch to train a part-

Release History

VersionChangesUrgencyDate
9.1.1Imported from PyPI (9.1.1)Low4/21/2026
v8.3.13- Add clear error message for float64 dtype mismatch in BLIS gemm (#461). - Document that Model.from_disk requires matching architecture (#751). - Document that Loss.get_grad computes gradient w.r.t. logits, not post-softmax probabilities (#901). - Remove stale comments about torch.cuda.amp.autocast migration (#967). - Fix numpy deprecation warning filter syntax in pyproject.toml. - Ignore NumPy 2.4 align deprecation from pickled dtype in test data.Medium3/23/2026
release-v8.3.12Our chain of libraries used Pydantic v1 in unusual ways and relied heavily on implementation details of what did and did not specifically pass Pydantic v1 type validation. Pydantic v2 greatly improved the behaviours of Pydantic overall, but unfortunately it broke the way we were using the library in Confection pretty fundamentally. The Pydantic v2 migration has been a blocker for full Python 3.14 support, as Pydantic v2 understandably didn't want to update their v1 shim for the 3.14 type-handLow3/21/2026
release-v8.3.11Release release-v8.3.11Low3/20/2026
release-v8.3.10Add wheels for Windows-ARM for Python 3.11-3.14. Python 3.10 wheels are skipped for this platform because there are no numpy Windows ARM wheels available for Python 3.10.Low11/17/2025
release-v8.3.9Add wheels for Python 3.14 and add some noexcept qualifiers to C functions.Low11/13/2025
release-v8.3.7* Widen numpy runtime dependency pin * Drop support for end-of-life Python 3.9 A release with Python3.14 wheels should be up shortly.Low11/6/2025
release-v8.3.6This release adds support for Python 3.13. In order to do this we're requiring Pydantic >= 2.0 and updated compilation to use Cython 3.0. This required an updated to theΒ blisΒ packaged that's not binary compatible, but thinc itself should not have any binary backwards compatibility issues.Low4/4/2025
release-v8.3.4Previous releases have used releases of our `blis` package that vendor newer releases of the upstream `blis` library. Unfortunately these newer releases have had intermittent crashes on Windows that we haven't been able to track down. I've therefore released a v1.2 of the `blis` package that goes back to the known-good v0.7 release of the vendored `blis` code, which we were using before. This release updates the verison-pin to use it. It took a surprisingly long time to get v0.7 of blis toLow1/13/2025
release-v8.3.3* Update blis pin to v1.1. This updates the vendored blis code to 1.1, which should fix crashes from the previously vendored v0.9 code on Windows. * Widen numpy pin, allowing versions across v1 and v2. Previously I had thought that if I build against numpy v2, I couldn't also have v1 as a runtime dependency. This is actually incorrect, so we can widen the numpy pin * Set flag on loading PyTorch models to improve safety of loading PyTorch models.Low12/16/2024
release-v8.3.2* Fix regression to torch training introduced in v8.3.1 * Restore MacOS ARM wheels, which were missing from previous builds * Fix compatibility with thinc-apple-opsLow10/1/2024
release-v8.3.1torch.cuda.amp is deprecated (Pytorch 2.4). This PR updates shims pytorch.py to use torch.amp.autocast instead of torch.cuda.amp.autocast. Thanks to @Atlogit for the patch.Low9/30/2024
release-v9.1.1Previously we used a complicated build process that used self-hosted runners to build wheels for platforms Github Actions did not support. Github Actions has been adding support for ARM recently, so we've simplified the CI process to rely only on it exclusively. This release adds back support for MacOS ARM64 wheels that were missing from the previous release. Linux ARM wheels are still pending, as Linux ARM architectures are currently only supported for private repos. Cross-compilation with QLow9/12/2024
release-v9.1.0Numpy is a build dependency of Thinc, and numpy 2.0 is not binary compatible with numpy 1.0 (fair enough). This means we can't have a version that's compatible across numpy v1 and numpy v2. This release updates v9 by pinning to numpy 2.0, and builds against it. No other changes are made, so that we have paired versions that only differ in their dependencies.Low9/2/2024
release-v8.3.0Numpy is a build dependency of Thinc, and numpy 2.0 is not binary compatible with numpy 1.0 (fair enough). This means we can't have a version that's compatible across numpy v1 and numpy v2. This release updates the pins to numpy 2.0 and builds against it. No other changes are made, so that we have paired versions that only differ in their dependencies.Low7/31/2024
v8.2.5Numpy v2.0 isn't binary compatible with v1 (understandably). We build against numpy so we need to restrict the pin.Low6/19/2024
v8.2.4## ✨ New features and improvements - Bump `nbconvert` pin - Bump `typing_extensions` pin for Python 3.7 - Updates to the test suite ## πŸ‘₯ Contributors @honnibal, @ines, @svlandegLow6/4/2024
v9.0.0> The main new feature of Thinc v9 is the support for [learning rate schedules](https://thinc.ai/docs/api-schedules#schedule) that can take the training dynamics into account. For example, the new [`plateau.v1`](https://thinc.ai/docs/api-schedules#plateau) schedule scales the learning rate when no progress has been found after a given number of evaluation steps. Another visible change is that [`AppleOps`](https://thinc.ai/docs/api-backends) is now part of Thinc, so it is not necessary anymore toLow4/19/2024
v8.2.3## πŸ”΄ Bug fixes - Make [strings2arrays](https://thinc.ai/docs/api-layers#strings2arrays) work again for sequences of inequal length (#918). - Fix `cupy.cublas` import (#921). ## πŸ‘₯ Contributors @danieldk, @honnibal, @ines, @svlandegLow2/7/2024
v8.2.2## ✨ New features and improvements Add the [ParametricAttention_v2](https://thinc.ai/docs/api-layers#parametricattention_v2) layer, which adds support for key transformations (#913). ## πŸ‘₯ Contributors @danieldk, @honnibal, @ines, @svlandegLow12/14/2023
v8.2.1## ✨ New features and improvements Updates and binary wheels for Python 3.12. ## πŸ‘₯ Contributors @adrianeboyd, @honnibal, @ines, @svlandeg Low9/22/2023
v8.2.0## ✨ New features and improvements To improve loading times and reduce conflicts, MXNet and TensorFlow are no longer imported automatically (#890). ## ⚠️ Backwards incompatibilities MXNet and TensorFlow support needs to be enabled explicitly. Previously, MXNet and TensorFlow were imported automatically if they were available in the current environment. To enable MXNet: ```python from thinc.api import enable_mxnet enable_mxnet() ``` To enable TensorFlow: ```python from thLow8/11/2023
v8.1.12## πŸ”΄ Bug fixes - Support zero-length batches and hidden sizes in `reduce_{max,mean,sum}` (#882). - Preserve values with dtype for `NumpyOps/CupyOps.asarray` (#897). ## πŸ‘₯ Contributors @adrianeboyd, @danieldk, @honnibal, @ines, @svlandegLow8/11/2023
v8.1.11## ✨ New features and improvements - Update NumPy build constraints for NumPy v1.25 (#885). - Switch from `distutils` to `setuptools`/`sysconfig` (#888). - Allow Pydantic v2 using transitional v1 support (#891). ## πŸ“– Documentation and examples - Fix typo in example code (#879). ## πŸ‘₯ Contributors @adrianeboyd, @Ankush-Chander, @danieldk, @honnibal, @ines, @svlandegLow8/7/2023
v8.1.10## ✨ New features and improvements * Implement `pad` as a CUDA kernel (#860). * Avoid h2d - d2h roundtrip when using `unflatten` (#861). * Improve exception when CuPy/PyTorch MPS is not installed (#863). * Lazily load custom `cupy` kernels (#870). ## πŸ”΄ Bug fixes * Initially load TorchScript models on CPU for MPS devices (#864). ## πŸ‘₯ Contributors @adrianeboyd, @danieldk, @honnibal, @ines, @shadeMe, @svlandegLow5/3/2023
v8.1.9## πŸ”΄ Bug fixes * Fix type signature of `Model.begin_update` (#858). ## πŸ‘₯ Contributors @danieldk, @honnibal, @inesLow3/7/2023
v8.1.8## ✨ New features and improvements * Add `premap_ids.v1` layer for mapping from ints to ints (#815). * Update to mypy 1.0.x (#848). ## πŸ”΄ Bug fixes * Make resizable layer work with textcat and transformers (#820). ## πŸ“– Documentation * Update website including `Dockerfile` (#843, #844, #845). ## πŸ‘₯ Contributors @adrianeboyd, @danieldk, @essenmitsosse, @honnibal, @ines, @kadarakos, @patjouk, @polm, @svlandegLow3/2/2023
v8.1.7## ✨ New features and improvements * Add `with_flatten.v2` layer with symmetric input/output types (#821). * Extend to `typing_extensions` v4.4.x for Python 3.6 and 3.7 (#833). ## πŸ“– Documentation * Update Gatsby for [thinc.ai](https://thinc.ai) (#827). ## πŸ‘₯ Contributors @adrianeboyd, @albertvillanova, @danieldk, @essenmitsosse, @honnibal, @ines, @shadchin, @shadeMe, @svlandeg Low1/13/2023
v8.1.6## ✨ New features and improvements * Update to mypy 0.990 (#801). * Extend to wasabi v1.1 (#813). * Add `SparseLinear.v2`, to fix indexing issues (#754). * Add `TorchScriptWrapper_v1` (#802). * Add callbacks to facilitate lazy-loading models in `PyTorchShim` (#796). * Make all layer defaults serializable (#808). ## πŸ”΄ Bug fixes * Add missing `packaging` requirement (#799). * Correct sequence length error messages for `reduce_first/last` (#807). * Update `CupyOps.asarray` to alwayLow12/20/2022
v8.1.5## ✨ New features and improvements * Updates and binary wheels for Python 3.11 (#793). * Make `__all__` static to support type checking (#780). ## πŸ‘₯ Contributors @adrianeboyd, @honnibal, @ines, @rmitsch Low10/19/2022
v7.4.6## ✨ New features and improvements * Updates for Python 3.10 and 3.11 (#791): * Update vendored `wrapt` to v1.14.1. * Update dev requirements. * Add wheels for Python 3.10 and 3.11. ## πŸ‘₯ Contributors @adrianeboyd, @honnibal, @inesLow10/18/2022
v8.1.4## πŸ”΄ Bug fixes * Fix issue #785: Revert change to return type for `Ops.alloc` from #779. ## πŸ‘₯ Contributors @adrianeboyd, @honnibal, @ines, @svlandegLow10/12/2022
v8.1.3## ✨ New features and improvements * Extend pydantic support to v1.10.x (#778). * Support mypy 0.98x, drop mypy support for Python 3.6 (#776). ## πŸ”΄ Bug fixes * Fix issue #775: Fix `fix_random_seed` entry point in `setup.cfg`. ## πŸ‘₯ Contributors @adrianeboyd, @honnibal, @ines, @pawamoy, @svlandegLow10/7/2022
v8.1.2## ✨ New features and improvements * Update CuPy extras to add `cuda116`, `cuda117`, `cuda11x` and `cuda-autodetect`, which uses the new `cupy-wheel` package (#740). * Add a pytest-randomly entry point for `fix_random_seed` (#748). ## πŸ”΄ Bug fixes * Fix issue #772: Restrict supported `blis` versions to `~=0.7.8` to avoid bugs in BLIS 0.9.0. ## πŸ‘₯ Contributors @adrianeboyd, @honnibal, @ines, @rmitsch, @svlandeg, @willfreyLow9/27/2022
v8.1.1## ✨ New features and improvements * Use [confection](https://github.com/explosion/confection) for configurations (#745). * Add the [Dish activation](https://thinc.ai/docs/api-backends#dish) function and [layer](https://thinc.ai/docs/api-layers#dish) (#719). * Add the [`with_signpost_interval`](https://thinc.ai/docs/api-layers#with_signpost_interval) layer to support layer profiling with macOS Instruments (#711). * Add [`remap_ids.v2`](https://thinc.ai/docs/api-layers#remap_ids) layer whicLow9/9/2022
v8.1.0## ✨ New features and improvements - Added support for mypy 0.950 and pydantic v1.9.0, added bound types throughout layers and ops (#599). - Made all `NumpyOps` CPU kernels generic (#627). - Made all custom CUDA kernels generic (#603). - Added bounds checks for `NumpyOps` (#618). - Fixed out-of-bounds writes in `NumpyOps` and `CupyOps` (#664). - Reduced unnecessary zero-init allocations (#632). - Fixed reductions when applied to zero-length sequences (#637). - Added `NumpyOps.cblas` toLow7/8/2022
v8.0.17## ✨ New features and improvements - Extend support for `typing_extensions` up to v4.1.x (for Python 3.7 and earlier). - Various fixes in the test suite. ## πŸ‘₯ Contributors @adrianeboyd, @danieldk, @honnibal, @ines, @shadeMe Low6/2/2022
v8.0.16## ✨ New features and improvements - Make [`Ops.asarray`](https://thinc.ai/docs/api-backends#asarray) implementations more robust. ## πŸ”΄ Bug fixes - Fix issue #624: Support CPU inference for models trained with gradient scaling. - Fix issue #633: Fix invalid indexing in `Beam` when no states have valid transitions. - Fix issue #639: Improve PyTorch `Tensor` handling in `CupyOps.asarray`. - Fix issue #649: Clamp inputs in `Ops.sigmoid` to prevent overflow. - Fix issue #651: Fix type Low5/19/2022
v8.0.15## πŸ”΄ Bug fixes - Fix issue #610: Improve compatibility with PyTorch versions before v1.9.0. ## πŸ‘₯ Contributors @adrianeboyd, @danieldkLow3/15/2022
v8.0.14## ✨ New features and improvements - Add new activation functions: [`ClippedLinear.v1`](https://thinc.ai/docs/api-layers#clippedlinear), [`Gelu.v1`](https://thinc.ai/docs/api-layers#gelu), [`HardSigmoid.v1`](https://thinc.ai/docs/api-layers#hardsigmoid), [`HardSwish.v1`](https://thinc.ai/docs/api-layers#hardswish), [`HardSwishMobilenet.v1`](https://thinc.ai/docs/api-layers#hardswishmobilenet), [`HardTanh.v1`](https://thinc.ai/docs/api-layers#hardtanh), [`ReluK.v1`](https://thinc.ai/docs/api-lLow3/14/2022
v8.0.12## πŸ”΄ Bug fixes - Fix issue #553: Switch torch tensor type with `set_ops` and `use_ops`. - Fix issue #554: Always restore original ops after `use_ops`. ## πŸ‘₯ Contributors @adrianeboyd, @danieldk, @ryndaniels, @svlandegLow10/28/2021
v8.0.11## ✨ New features and improvements - Speed up GPU training time with up to ~25% by using cuBLAS for computing Frobenius norms in gradient clipping. - Give preference to [`AppleOps`](https://github.com/explosion/thinc-apple-ops) (if available) when calling `get_ops("cpu")`. - Support missing values in `CategoricalCrossEntropy` when the labels are integers. - Provide the option to run [`model.walk`](https://thinc.ai/docs/api-model#walk) with depth-first traversal. - Wrap `forward`/`init` caLow10/20/2021
v8.0.10## πŸ”΄ Bug fixes - Fix issue #533: Fix `get_array_ops` for numpy arrays. ## πŸ‘₯ Contributors @adrianeboydLow9/7/2021
v8.0.9## ✨ New features and improvements - Add `ops` registry. - Enable config overrides to add new keys. - Allow newer releases of `nbconvert` and `nbformat`. - Layer for marking [NVTX ranges](https://thinc.ai/docs/api-layers#with_nvtx_range). - Support mixed-precision training in the PyTorch shim (experimental). ## πŸ”΄ Bug fixes - Fix issue #521: Fix `numpy_ops` `gemm` output. - Fix issue #525: Fix `mypy` plugin crash on variadic arguments. ## πŸ‘₯ Contributors @adrianeboyd, @connorLow9/3/2021
v8.0.8## ✨ New features and improvements - Allow negated values in CategoricalCrossentropy Low7/19/2021
v8.0.7## πŸ”΄ Bug fixes * Fix issue #512: Include final n-gram in `NumpyOps.ngrams`. * Fix issue #516: Update initializers for typing in numpy 1.21+.Low7/1/2021
v8.0.6## πŸ”΄ Bug fixes * Fix `backprop_reduce_max` GPU kernel.Low7/1/2021
v8.0.5## ✨ New features and improvements * Update to support torch v1.9.0.Low6/16/2021
v8.0.4 ## ✨ New features and improvements * Add `tuplify` layer. * More generic implementation of the `concatenate` layer. * Add `resizable` layer. * Introduce `force` parameter for `model.set_dim()`. * Improve UX when setting the GPU allocator. ## πŸ”΄ Bug fixes * Fix issue #492: Fix backpropagation in `with_getitem`. * Fix issue #494: Resolve forward refs issue with Pydantic. * Fix issue #496: Avoid Pydantic versions with security vulnerabilities. ## πŸ‘₯ Contributors @adrianeboyd,Low6/11/2021
v8.0.3## πŸ”΄ Bug fixes * Fix issue #486: Fix `expand_window` for empty docs on GPU * Fix issue #487: Require `catalogue>=2.0.3` due to performance regressions related to `importlib-metadata` * Fix issue #488: Fix config override & interpolate interactionLow4/19/2021
v8.0.2## ✨ New features and improvements * Add `map_list` layer (#472) ## πŸ”΄ Bug fixes * Fix issue #465: Fix saving models to Pathy paths * Fix issue #466: Avoid initializing with Y if X is set * Fix issue #470: Reset torch tensor type in `require_cpu` * Fix issue #484: Ensure consistency of nO dim for BiLSTMLow3/9/2021

Dependencies & License Audit

Loading dependencies...

Similar Packages

azure-search-documentsMicrosoft Azure Cognitive Search Client Library for Pythonazure-template_0.1.0b6187637
apache-tvm-ffitvm ffi0.1.10
luqumA Lucene query parser generating ElasticSearch queries and more !1.0.0
torchaoPackage for applying ao techniques to GPU models0.17.0
banksA prompt programming language2.4.1