Skip to main content
Cluster stage showing semantic grouping of search results
The Cluster stage groups documents based on embedding similarity, creating semantic clusters of related content. This helps organize search results into meaningful groups and discover themes within your results.
Stage Category: GROUP (Groups documents)Transformation: N documents → K clusters with documents

When to Use

When NOT to Use

Parameters

Clustering Algorithms

auto runs one lightweight LLM call on the first batch — given sample size, dimensionality, variance, and intended cluster count — and locks in a concrete algorithm. Rides the wave: upgrading the LLM improves selection without code changes. Falls back to kmeans if the LLM call fails.

Configuration Examples

How Clustering Works

  1. Extract Embeddings: Get embedding vectors from each document
  2. Apply Algorithm: Run clustering algorithm (e.g., k-means)
  3. Assign Documents: Each document assigned to nearest cluster
  4. Compute Centroids: Calculate cluster centers
  5. Label (optional): Generate human-readable cluster names

Output Schema

Performance

Clustering large document sets (10K+) can be slow. Consider pre-filtering or sampling before clustering.

Common Pipeline Patterns

Search + Cluster

Cluster + Sample Representatives

Theme Discovery Pipeline

Diverse Results Pipeline

Cluster Labeling

When label_clusters: true, an LLM generates descriptive labels:

Choosing num_clusters

Start with fewer clusters and increase if clusters are too broad. Use HDBSCAN if you don’t know the optimal number.

Error Handling