Notebooks
O
OpenAI
Visualizing Embeddings In 3D

Visualizing Embeddings In 3D

chatgptopenaigpt-4examplesopenai-apiopenai-cookbook

Visualizing embeddings in 3D

The example uses PCA to reduce the dimensionality fo the embeddings from 1536 to 3. Then we can visualize the data points in a 3D plot. The small dataset dbpedia_samples.jsonl is curated by randomly sampling 200 samples from DBpedia validation dataset.

1. Load the dataset and query embeddings

[1]
Categories of DBpedia samples: Artist                    21
Film                      19
Plant                     19
OfficeHolder              18
Company                   17
NaturalPlace              16
Athlete                   16
Village                   12
WrittenWork               11
Building                  11
Album                     11
Animal                    11
EducationalInstitution    10
MeanOfTransportation       8
Name: category, dtype: int64
[2]

2. Reduce the embedding dimensionality

[3]

3. Plot the embeddings of lower dimensionality

[4]
<matplotlib.legend.Legend at 0x1622180a0>
Output