Skip to main content

embedding-visualizer

Interactive 2D visualization of text embeddings using OpenAI's embedding API and Plotly.

Install

pip install embedding-visualizer

Or in dev mode:

cd embedding_visualizer
uv sync

Requires an OPENAI_API_KEY environment variable.

Usage

from embedding_visualizer import visualize_embeddings, PrincipalComponent, TextEmbedding

docs = [
    {
        "text": "This text will be embedded",
        "label": "optional, groups points in the legend",
        "color": "optional, color for the point/label group",
        "line-id": "optional, connects points with the same id",
        "hover": "optional hover text",
    },
    # ...
]

# t-SNE or PCA projection
plot = visualize_embeddings(docs=docs, projection="t-sne")  # or "pca"

# Custom per-axis projection
plot = visualize_embeddings(
    docs=docs,
    x_projection=PrincipalComponent(1),
    y_projection=TextEmbedding("some text to project onto"),
    title="My Embedding Plot",
)

plot.display()              # show in Jupyter or browser
plot.to_html("plot.html")   # self-contained HTML file

Doc fields

Field Required Description
text yes Text to embed
label no Legend group name; points with the same label share a color
color no Point color. If label is set, applies to the whole group
line-id no Connects points with the same id in document order
hover no Custom hover text (defaults to first 100 chars of text)

Projections

  • projection="t-sne" — t-SNE with cosine metric (default)
  • projection="pca" — PCA
  • PrincipalComponent(n) — project onto the nth principal component (1-indexed)
  • TextEmbedding("text") — cosine similarity with a reference text's embedding

Example

examples/repo_files.py embeds every Python file in this repository at multiple truncation points and connects versions of the same file with lines:

uv run python examples/repo_files.py

Caching

Embeddings are cached to ~/.cache/embedding_visualizer/ so repeated runs don't re-call the API.

Metadata

Release files for embedding-visualizer 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for embedding-visualizer 0.1.2
File Size Uploaded Provenance Actions
embedding_visualizer-0.1.2.tar.gz 106.1 kB With provenance Details for embedding_visualizer-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for embedding-visualizer 0.1.2
File Interpreter ABI Platform Actions
embedding_visualizer-0.1.2-py3-none-any.whl Python 3 none any Details for embedding_visualizer-0.1.2-py3-none-any.whl

Total release size: 113.2 kB

Release files / embedding_visualizer-0.1.2.tar.gz

Download URL embedding_visualizer-0.1.2.tar.gz
Size 106.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3c4c898d40306c9c3f77d822389a946c398b461326e5d2cf9c8102537af02ad1
BLAKE2b-256 checksum
How to use checksums
d6bfc4f409d63d6c0372765f13be8b376692b2f0f1359cad69ebd76e5e75f692
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Feb 21, 2026.

Transparency log

Release files / embedding_visualizer-0.1.2-py3-none-any.whl

Download URL embedding_visualizer-0.1.2-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1d979f1cfd1512a8e2065c3addfeafc819842d23e8f0fb181c86c875f9e3483
BLAKE2b-256 checksum
How to use checksums
3210b0ad266421a6a43fc238f2f6114357287a35dfa6dde43fc315b747b143ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Feb 21, 2026.

Transparency log

Security for embedding-visualizer 0.1.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for embedding_visualizer-0.1.2.tar.gz

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 Feb 21, 2026.

Transparency log

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.

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