Skip to main content

pyhighlights

Tests Documentation PyPI

Research library for highlight-based explainable AI models.

Documentation · Contributing

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)

Source distribution for pyhighlights 0.1.0
File Size Uploaded
pyhighlights-0.1.0.tar.gz 24.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyhighlights 0.1.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page