Skip to content
Sign in
KnowledgeEmbedding mapMenu

Embedding mapPro

A 2D projection of chunks with clusters, the query as a point and lines to the neighbors it retrieved.

ProSix clusters of a support corpus; switch the query and its eight neighbors re-link on the map.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/embedding-map

Usage

tsx
import { EmbeddingMap } from "@/components/ui/chatcn/pro/embedding-map"

<EmbeddingMap
  points={points}
  clusters={clusters}
  query={{ text, x, y }}
  neighbors={retrieved}
/>

Project your vectors with UMAP or t-SNE and pass the coordinates; projectEmbeddings in chatcn-pro-rag-a does a dependency free PCA in the browser for a few thousand chunks. The map keeps the aspect so distances stay honest. Points stay one memoized layer, so panning thousands of them is smooth. A miss is easy to spot: the right chunk sits in another cluster with no line to it.

Examples

States

ProNo query with a pinned point and a hidden cluster, a dense corpus, projecting, failed and empty.

Props

PropTypeNotes
pointsEmbeddingPoint[]{ id, x, y, cluster?, source?, text? }
clusters{ id, label, color? }[]Chart colors 1 to 6
query{ text, x, y }The query projected into the same space
neighbors{ id, score }[]Best first; the top five get rank labels
selectedId, hiddenClusterscontrolled or defaultPinned point and hidden clusters
loading, progress, error, onRetryProjection states
method, heightstring, number | stringHeader note and plot height

Keyboard

KeyAction
Arrow keys on the mapPan
+ and -Zoom in and out
0Fit all points
EscapeClear the pinned point
TabZoom buttons, cluster toggles, then the neighbor list

Accessibility

  • The map is an image with a summary; the neighbor list beside it carries the same data as buttons.
  • Cluster toggles are pressed buttons with the count in their name.
  • Ctrl or Cmd and scroll zooms, so the page still scrolls under a plain wheel.

Motion

When a query lands its lines fade in by rank, 40 ms apart, and the query mark ripples once. Zoom and pan follow the pointer directly. Reduced motion drops the ripple and the stagger and keeps a short fade.