entmax
The entmax mapping and its loss, a family of sparse alternatives to softmax.
Decision gist · record as of 2026-08-14
Yes, if you need sparse probability mappings or attention in PyTorch. The package is well-designed, permissively licensed, and has low install friction. Dormant maintenance is a minor concern—check compatibility with your PyTorch version before adopting in production, and verify that the bisection algorithms meet your numerical stability requirements. For research and prototyping, it is a solid choice.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires PyTorch >= 1.9; Python >= 3.5.
- Low friction: pure Python wheel with only torch as a runtime dependency.
- Maintenance is dormant (last release February 2024, last commit June 2024), but the repository remains active and unarchived with modest community interest (474 stars).
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute entmax freely in commercial and private projects without restriction.
last release 2024-02-07 (919 days) · last repo commit 2024-06-22 · 474 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 105,484 downloads/mo, #12,696 on PyPI
Alternatives
Verify before relying
pip install entmax
import torch
from entmax import sparsemax, entmax15, entmax_bisect
x = torch.tensor([-2, 0, 0.5])
result = sparsemax(x, dim=0) # tensor([0.0000, 0.2500, 0.7500])
alpha = torch.tensor(1.33, requires_grad=True)
p = entmax_bisect(x.unsqueeze(0), alpha)- Whether the dormant maintenance status (919 days since last release) affects compatibility with recent PyTorch versions.
- Performance characteristics and numerical stability compared to other sparse attention implementations.
- Whether gradient computation w.r.t. alpha is production-ready or primarily for research.
What it is and what it does
Entmax is a PyTorch library that implements entmax—a family of sparse probability mappings that generalize softmax by introducing sparsity. Instead of softmax's dense output where all values are non-zero, entmax can produce sparse distributions where many values become exactly zero, useful for attention mechanisms and multi-label classification. The package includes exact partial-sort algorithms for common cases (1.5-entmax and 2-entmax/sparsemax) and a general bisection-based algorithm for arbitrary alpha values, plus support for gradients with respect to alpha itself for learned, adaptive sparsity.
The library depends only on torch and installs as a pure Python wheel with low friction. It is designed for researchers and practitioners building sparse sequence models, adaptive transformers, and other architectures where sparse attention or sparse probability distributions are beneficial. The code is well-documented with examples and academic citations, though maintenance is dormant—the last release was in February 2024.
Use it for
- Build sparse attention mechanisms in transformer models where only a subset of positions need non-zero attention weights.
- Implement multi-label classification with sparse output distributions instead of dense softmax probabilities.
- Learn adaptive sparsity patterns by computing gradients with respect to the alpha parameter during training.
- Replace softmax in sequence-to-sequence models to reduce computational cost and improve interpretability through explicit sparsity.
- Experiment with sparse transformers and other architectures that benefit from learned, structured sparsity in attention.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need sparse probability mappings or attention in PyTorch.
The package is well-designed, permissively licensed, and has low install friction. Dormant maintenance is a minor concern—check compatibility with your PyTorch version before adopting in production, and verify that the bisection algorithms meet your numerical stability requirements. For research and prototyping, it is a solid choice.
Install
entmax on PyPI
Before you install
Low friction: pure Python wheel with only torch as a runtime dependency. Maintenance is dormant (last release February 2024, last commit June 2024), but the repository remains active and unarchived with modest community interest (474 stars).
Requires PyTorch >= 1.9; Python >= 3.5.
License in practice
MIT license is permissive; you can use, modify, and distribute entmax freely in commercial and private projects without restriction.
Quickstart
pip install entmax
import torch
from entmax import sparsemax, entmax15, entmax_bisect
x = torch.tensor([-2, 0, 0.5])
result = sparsemax(x, dim=0) # tensor([0.0000, 0.2500, 0.7500])
alpha = torch.tensor(1.33, requires_grad=True)
p = entmax_bisect(x.unsqueeze(0), alpha)
Verify before relying
- Whether the dormant maintenance status (919 days since last release) affects compatibility with recent PyTorch versions.
- Performance characteristics and numerical stability compared to other sparse attention implementations.
- Whether gradient computation w.r.t. alpha is production-ready or primarily for research.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.5 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetorch |
| Maintenance | Dormant 919 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 105,484 / month, #12,696 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: entmax-1.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “sparse softmax alternative pytorch”
- entmaxEntmax provides PyTorch implementations of entmax and entmax…
- sae-lensSAE Lens trains and analyzes sparse autoencoders for mechanistic…
- nvidia-cusparse-cu12Provides NVIDIA CUSPARSE native runtime libraries for GPU-accelerated…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also cut-cross-entropy · captum · torchmetrics · torch-optimizer · rotary-embedding-torch · nvidia-cusparselt-cu13 · pytorch-metric-learning · nvidia-cusparselt-cu12 · efficientnet-pytorch · vit-pytorch