pyhighlights
Research library for highlight-based explainable AI models.
Installation
pip install pyhighlights
Use pip install "pyhighlights[transformers]" for Transformer backends.
GRU folded rationalization
from pathlib import Path
import pyhighlights
from cinnamon.registry import Registry
from pyhighlights.configurations.spp import (
GRU_FR,
GRU_GRAT,
GRU_MCD,
GRU_MGR,
TRANSFORMER_FR,
)
Registry.build(directory=Path(pyhighlights.__file__).parent)
fr = Registry.from_key(GRU_FR)
mgr = Registry.from_key(GRU_MGR)
mcd = Registry.from_key(GRU_MCD)
grat = Registry.from_key(GRU_GRAT)
transformer_fr = Registry.from_key(TRANSFORMER_FR) # needs pyhighlights[transformers]
GRU and Transformer implementations conform to same backbone interface; model classes contain rationalization logic only.
Highlight data
from torch.utils.data import DataLoader
from pyhighlights.components import (
HighlightCollator,
HighlightDataset,
HighlightExample,
VocabularyTokenizer,
)
examples = HighlightDataset([
HighlightExample(0, ["great", "stay"], label=1, highlights=[1, 0]),
HighlightExample(1, ["bad"], label=0), # unlabeled highlights become -1
])
collator = HighlightCollator(VocabularyTokenizer({"great": 1, "stay": 2, "bad": 3}))
batch = next(iter(DataLoader(examples, batch_size=2, collate_fn=collator)))
HuggingFaceTokenizer expands word highlights across subtokens and requires
pyhighlights[transformers].
Metadata
Release files for pyhighlights 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyhighlights-0.1.0.tar.gz | 24.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyhighlights-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.2 kB
Release files / pyhighlights-0.1.0.tar.gz
| Download URL | pyhighlights-0.1.0.tar.gz |
|---|---|
| Size | 24.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ee03477224863c257241d552e72f5af38563fbe32650c836732f30ce0ba73d2
|
|
BLAKE2b-256 checksum How to use checksums |
a79ec649791d2a00e9962696b820215e99bd431c5fb3bd2ce4156bff56a54dc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logRelease files / pyhighlights-0.1.0-py3-none-any.whl
| Download URL | pyhighlights-0.1.0-py3-none-any.whl |
|---|---|
| Size | 25.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d66bd4a6174abd0ae24d56a56118b95d93d5e5b13f27bc286ec8f0e58f16aca
|
|
BLAKE2b-256 checksum How to use checksums |
6c7249b4d6953cdfbf1ca6368ae8b5188ede4dbc0fec8d3d1f976b460da7a2b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency log