Models

What Is t-SNE?

t-distributed Stochastic Neighbor Embedding — a non-linear dimensionality-reduction algorithm that projects high-dimensional vectors into 2 or 3 dimensions while preserving local neighborhoods.

What Is t-SNE?

t-SNE — t-distributed Stochastic Neighbor Embedding — is a non-linear dimensionality-reduction algorithm published by van der Maaten and Hinton in 2008. It projects high-dimensional points (typically a few hundred to a few thousand dimensions) into 2 or 3 dimensions for visualization. The algorithm models pairwise similarity between points in the original space as a probability distribution and tries to reproduce that distribution in the low-dimensional space, using a heavy-tailed Student-t distribution to push moderately distant points further apart and keep clusters visually separable. For LLM teams it is the standard way to inspect embeddings: cluster structure, drift, and fine-tune effect become visible in a 2D scatter plot.

Why It Matters in Production LLM and Agent Systems

Embeddings drive retrieval in every RAG system and routing in many agent stacks, but they live in spaces no human can see directly. A 1536-dimensional OpenAI embedding is a number; what a team needs to see is whether the model puts “refund-policy” close to “return-policy” and far from “shipping-tracking.” t-SNE is the visualization that turns the vector store into a picture, and the picture is often where regression first appears: a model swap that compresses one cluster, a fine-tune that splits a previously cohesive topic into two, a new chunking strategy that scrambles a previously clean structure.

The pain is felt by ML and platform engineers debugging retrieval. A team upgrading an embedding model sees retrieval quality drop without an obvious cause; a t-SNE projection of the old vs. new index shows that several semantically distinct topics have collapsed into a single cluster — the new model is less discriminative on the team’s domain. RAG engineers seeing high ChunkAttribution failure rates inspect the t-SNE plot and find a chunk-size change has produced dozens of near-duplicate clusters. Drift teams use t-SNE side-by-side comparisons to spot distribution shift between training-time embeddings and production embeddings.

For 2026 agent stacks where memory, retrieval, and routing all share an embedding space, the cost of a silent embedding regression is high: every downstream component degrades together. t-SNE is the cheapest way to see whether the embedding space still has the structure you assumed.

How FutureAGI Handles t-SNE

FutureAGI does not provide a t-SNE visualization tool itself — that is what notebooks, dashboards, and the SDK in your data-science stack are for. What FutureAGI does is make the underlying numbers actionable. The pattern teams use is to export embeddings from a Dataset (computed via the FutureAGI SDK or your embedding provider), run t-SNE locally for visualization, and run EmbeddingSimilarity from fi.evals for the quantitative claim. The visualization tells you “something looks wrong”; the evaluator tells you how wrong, on which cohort, and whether it crosses the regression threshold.

Concretely: a RAG team upgrading from text-embedding-ada-002 to text-embedding-3-large exports both embedding sets for their corpus, plots a side-by-side t-SNE, and sees that the customer-support cluster has fragmented. To quantify, they compute EmbeddingSimilarity between matched chunks in the old and new spaces and find a 0.18 mean drop on support docs vs. 0.04 elsewhere. They re-tune their reranker on the new model for that cohort and ship. The t-SNE caught the visual anomaly; the evaluator turned it into a number that gated the deploy. FutureAGI’s role is the second half — the regression eval, the threshold, the dashboard — not the picture.

How to Measure or Detect It

t-SNE is a visualization aid, not a metric — but the metrics it points at are real:

  • EmbeddingSimilarity: cosine similarity between matched embeddings; the canonical drift number after a t-SNE plot raises a flag.
  • Cluster-purity score (computed externally): for a labeled subset, fraction of nearest-neighbors that share the label; quantifies whether t-SNE clusters reflect ground-truth structure.
  • Per-cohort similarity drop (dashboard signal): EmbeddingSimilarity between old and new embedding versions sliced by topic; surfaces uneven impact.
  • Retrieval ChunkAttribution rate: downstream signal that an embedding regression hurts retrieval.
  • Visual stability between runs: t-SNE is non-deterministic; pin perplexity and seed before comparing plots, or you’ll see noise.

Minimal Python:

from fi.evals import EmbeddingSimilarity

sim = EmbeddingSimilarity()
result = sim.evaluate(
    response=new_embedding_text,
    expected_response=old_embedding_text,
)
print(result.score)

Common Mistakes

  • Reading global distances off the plot. t-SNE preserves local neighborhoods, not global geometry. Two clusters drawn far apart are not necessarily semantically far.
  • Comparing two t-SNE plots without fixing perplexity and seed. Different runs produce visibly different layouts of the same data; the comparison is meaningless without controls.
  • Treating t-SNE as a metric. It is a visualization. Quantify the differences with EmbeddingSimilarity or cluster-purity scores before claiming drift.
  • Plotting the entire corpus. t-SNE scales poorly past ~50K points; sample by cohort and plot per-topic to see structure that aggregates hide.
  • Confusing t-SNE with UMAP. UMAP is faster, often gives more meaningful global distances, and is reproducible across runs. Use UMAP for production dashboards and t-SNE for one-off inspection.

Frequently Asked Questions

What is t-SNE?

t-SNE is a non-linear dimensionality-reduction algorithm that projects high-dimensional vectors — typically embeddings — into 2 or 3 dimensions for visualization, preserving local neighborhood structure.

How is t-SNE different from PCA?

PCA is a linear projection that preserves global variance; it is fast and reversible. t-SNE is non-linear and preserves local neighborhoods, producing better cluster visualizations but no meaningful global distances or reverse mapping.

Where does t-SNE fit in an LLM workflow?

FutureAGI teams use t-SNE to visually inspect embeddings for clustering, drift between embedding-model versions, or fine-tune impact, then quantify the actual differences with EmbeddingSimilarity rather than reading distances off the plot.