Visualize Data Embeddings with Kangas
A notebook that builds a Kangas DataGrid with 2D embedding projections, colored by score and groupable in the browser.
Why it matters
Visualize high-dimensional data embeddings in a 2D projection using the Kangas DataGrid. This asset helps in understanding data relationships and patterns by rendering embeddings with color-coded scores.
Outcomes
What it gets done
Load data and embeddings into a Kangas DataGrid.
Convert numerical embeddings to a dedicated Embedding datatype.
Render 2D projections of embeddings, color-coded by score.
Group data points by score for analysis.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/oai-visualizingembeddingsinkangas | bash Steps
Steps in the chain
Overview
Visualizing Embeddings In Kangas
A notebook that loads review data and embeddings into a Kangas DataGrid, converts them into a proper Embedding column, and renders a 2D projection colored and groupable by score. Use it when you want to inspect embeddings and their projections in a dataframe-native tool colored by score - it's built around Kangas' own rendering, not a general plotting library.
What it does
This notebook builds a Kangas DataGrid containing review data alongside 2D projections of their embeddings. Kangas is an open-source, mixed-media, dataframe-like tool for data scientists built by Comet, a company focused on reducing friction in moving models to production.
After installing Kangas, the notebook reads a CSV of reviews (each with a 1536-float embedding) directly from GitHub - so the notebook works even outside OpenAI's own repo - into a DataGrid, inspects its fields and sample rows, then converts the raw embedding numbers into a proper Embedding-typed column and saves the DataGrid. Rendering the DataGrid directly in the notebook shows each row with its embedding projection visible by scrolling right; the projection point's color represents the review's Score, and grouping by Score clusters rows by group. A hosted example of the resulting DataGrid is linked for reference.
When to use - and when NOT to
Use it when you want an interactive, dataframe-native way to inspect embeddings alongside their source data and a score field - reviewing projection clusters by score, without exporting to a separate visualization tool. It's built around Kangas' own DataGrid rendering rather than a general-purpose plotting library, so it fits best when Kangas (or Comet's broader tooling) is already part of your workflow.
Inputs and outputs
Input is a CSV of text data with an associated 1536-dimension embedding per row and a score field. Output is a saved Kangas DataGrid with an Embedding-typed column and a rendered 2D projection, viewable and groupable directly in the notebook or via a hosted Kangas link.
Integrations
It uses the Kangas Python library (pip install kangas) for DataGrid construction and 2D projection rendering, reading source data from a CSV hosted on GitHub.
Who it's for
Data scientists who want to explore embeddings and their projections inside a dataframe-native tool, colored and grouped by an existing score field, rather than building a separate plotting pipeline.
Source README
Visualizing the embeddings in Kangas
In this Jupyter Notebook, we construct a Kangas DataGrid containing the data and projections of the embeddings into 2 dimensions.
What is Kangas?
Kangas as an open source, mixed-media, dataframe-like tool for data scientists. It was developed by Comet, a company designed to help reduce the friction of moving models into production.
1. Setup
To get started, we pip install kangas, and import it.
2. Constructing a Kangas DataGrid
We create a Kangas Datagrid with the original data and the embeddings. The data is composed of a rows of reviews, and the embeddings are composed of 1536 floating-point values. In this example, we get the data directly from github, in case you aren't running this notebook inside OpenAI's repo.
We use Kangas to read the CSV file into a DataGrid for further processing.
We can review the fields of the CSV file:
And get a glimpse of the first and last rows:
Now, we create a new DataGrid, converting the numbers into an Embedding:
The new DataGrid now has an Embedding column with proper datatype.
We simply save the datagrid, and we're done.
3. Render 2D Projections
To render the data directly in the notebook, simply show it. Note that each row contains an embedding projection.
Scroll to far right to see embeddings projection per row.
The color of the point in projection space represents the Score.
Group by "Score" to see rows of each group.
An example of this datagrid is hosted here: https://kangas.comet.com/?datagrid=/data/openai_embeddings.datagrid
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.