Skip to main content

Glyph

Glyph

Glyph automates discovery in foundation-model embeddings. It learns sparse concepts, searches for associations with outcomes, and summarizes its findings in interactive visualizations and concise reports. Use it on your own data, or apply the pretrained concept dictionaries released with the paper.

Demos

See Glyph run on public images, with executed notebooks, interactive concept maps and illustrated reports.

Demo Notebook PDF report Interactive HTML
Skin-lesion diagnosis · 1,373 patients, clinical baseline Open notebook View report Get HTML
Chest X-ray mortality · 948 patients, clinical baseline Open notebook View report Get HTML
Handwritten digits · 1,000 images, ten digit labels Open notebook View report Get HTML

GitHub displays the notebooks and PDFs. Download an HTML file and open it in your browser to use the interactive explorer.

Install

pip install "glyph-discovery[hf,zoo]"

The source repository is StanfordMIMI/Glyph.

For the paper's pretrained dictionaries, install the matching encoder extra: pip install "glyph-discovery[zoo,ct]", "glyph-discovery[zoo,text]", or "glyph-discovery[zoo,labs]". Model weights download when needed. DINOv3 requires approved access to its HF checkpoint.

Learn new concepts

from glyph import Glyph

glyph = Glyph(config_path='config', config_overrides=[
    'data.metadata=/path/to/metadata.csv',
    'data.input_cols=[image_path]',
    'data.outcome_cols=[pneumonia]',
    'data.embedding_map={image_path: "hf:facebook/dinov3-vits16-pretrain-lvd1689m"}',
    'data.embedding_model_kwargs={image_path: {input_type: image, pooling: cls}}',
])

glyph.fit()
glyph.hypothesis_search()
glyph.visualize(outcome='pneumonia', split='test')

The metadata supplies study IDs, image paths, and outcome labels. fit favors sparse SAE configurations using validation reconstruction R² and warns below 0.85. hypothesis_search tests concept–outcome associations; visualize shows an interactive concept space with association statistics and significant concepts highlighted. Node area reflects activation prevalence, and correlation links are visible by default with at most eight per concept. Confounder adjustment and automated interpretation are optional. Labels are not required for learning and exploring concepts.

For a small text encoder, use qwen3-embedding-0.6b. Other HF models and your own models can specify their preprocessing and embedding output; see the encoder guide.

Extract the paper's concepts on your data

from glyph import Glyph

# 1. EXTRACT A SINGLE PUBLISHED CONCEPT ON YOUR DATA
ct = Glyph.from_pretrained('ct-merlin')
i87 = ct.measure('I87', metadata='ct_metadata.csv')

# Optionally select one study by its ID in your metadata.
i87 = ct.measure('I87', metadata='ct_metadata.csv', sample_id='scan_001')

# 2. EXTRACT THE FULL PRETRAINED CONCEPT SPACE ON YOUR DATA
labs = Glyph.from_pretrained('labs-loinc')
concepts = labs.measure(metadata='labs_metadata.csv')
labs.visualize()

# Select an individual concept from the measured space.
l127 = concepts['L127']

ct_metadata.csv contains sample_id and image_path (CT NIfTI paths). labs_metadata.csv contains sample_id and labs_path (prepared laboratory JSON paths); see lab preparation for raw LOINC data.

from_pretrained loads the published SAE. measure computes the matching foundation-model embeddings on your data, then applies that SAE. No labels, SAE training, or train/test splits are needed. Repeated requests reuse measured studies; missing studies are encoded when requested.

A single concept returns a Series indexed by study ID. Whole-space extraction returns all 8,192 original concept columns in a DataFrame. The explorer shows concepts active in your cohort and available published interpretations; labels are needed for association testing and significance highlighting.

Bundles are ct-merlin, findings-qwen3, and labs-loinc. Each preserves the paper's normalization and concept indices and uses the original matching encoder. See extraction and saved runs for supplied embeddings, reloading, and input options.

Run through a coding agent

The package includes skills for using Glyph, literature comparisons, interactive HTML, and brief visual reports. Install them for your coding agent:

glyph skills install --agent claude   # or --agent codex
glyph skills list

Then ask, for example:

Run Glyph on my cohort.
Metadata: /path/to/metadata.csv
Inputs: image_path
Outcome: pneumonia
Encoder: hf:facebook/dinov3-vits16-pretrain-lvd1689m, using CLS pooling.

Report reconstruction R², draw the concept map, and list associated concepts
with odds ratios and Bonferroni significance. Compare against source-backed
literature markers and produce a brief visual report.

If my inputs match a modality in the paper, apply its pretrained concepts with
the matching encoder instead of fitting a new dictionary, and assess the
associations in my cohort.

Interpretation through Gemini/Vertex and supplementary literature search through Paperclip are optional and require configured access. Numerical analyses and visualization do not require an LLM key.

Documentation · Agent harnesses · Remote HTML viewing

Metadata

Release files for glyph-discovery 0.2.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 glyph-discovery 0.2.0
File Size Uploaded Provenance Actions
glyph_discovery-0.2.0.tar.gz 248.6 kB Without provenance Details for glyph_discovery-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for glyph-discovery 0.2.0
File Interpreter ABI Platform Actions
glyph_discovery-0.2.0-py3-none-any.whl Python 3 none any Details for glyph_discovery-0.2.0-py3-none-any.whl

Total release size: 457.2 kB

Release files / glyph_discovery-0.2.0.tar.gz

Download URL glyph_discovery-0.2.0.tar.gz
Size 248.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c100b5b1d8e279c01d47a964c1782f41ac17c3b7c7b6e7487044835a76b34095
BLAKE2b-256 checksum
How to use checksums
2fb6d90ca8d8f755e5cae90a9da5748fe15b1d2f7f3caab3913107c3197dc8d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / glyph_discovery-0.2.0-py3-none-any.whl

Download URL glyph_discovery-0.2.0-py3-none-any.whl
Size 208.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddd07e5e332e24cbdc7aea746aa86e03a140751372eec5309ec65f159978721d
BLAKE2b-256 checksum
How to use checksums
90879dfba636c90dd1f4ca7861669ba11edcb70afe63d2d375637681171cbae5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for glyph-discovery 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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