Topic discovery
Organize a large text corpus into discovered themes.
AI & ML · Const
Clustering groups text by similarity using semantically meaningful embedding vectors. It is an unsupervised way to uncover hidden groupings in a large text dataset.
Clustering applies an unsupervised grouping algorithm to embedding vectors so semantically similar text is assigned to the same group.
Cluster labels for the embedded text items; the page demonstrates storing them in a Cluster column.
from sklearn.cluster import KMeans
import numpy as np
embeddings = np.array([
[1.0, 0.0], [0.9, 0.1],
[0.0, 1.0], [0.1, 0.9],
])
model = KMeans(n_clusters=2, init="k-means++", random_state=42)
model.fit(embeddings)
print(model.labels_)This runnable example groups embedding vectors into two clusters with K-means.
Organize a large text corpus into discovered themes.
Separate favorable and unfavorable review patterns.
Identify groups of semantically related documents.
OpenAI embeddings convert text into vectors that preserve aspects of content or meaning. A clustering algorithm can then group vectors according to similarity.
Follow-up: Why are embeddings useful before clustering? Similar text tends to produce vectors that are closer together than unrelated text.
Clustering is useful when the dataset has no predefined labels and the goal is to discover latent groups. The documentation presents textual data as the input and embedding vectors as the representation.
Follow-up: What does the output mean? Each item receives a cluster assignment, which should be interpreted by examining the text in each group.
A practical workflow is to create embeddings, arrange them into a matrix, select a cluster count, fit K-means, and store the resulting labels. The documentation example uses four clusters and k-means++ initialization.
Follow-up: What should be checked after fitting? Inspect whether the groups are coherent and whether the selected cluster count reflects the task.
EmbeddingsSearchRecommendationsAnomaly detectionClassificationKMeans