Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Quick tip: Visualise OpenAI Vector Embeddings using Plotly Express

Posted on Aug 13 This article demonstrates how to visualise OpenAI Vector Embeddings for a search term using t-SNE and Plotly Express. We build on the work from a previous article, where we showed how to adapt an OpenAI example to work with SingleStoreDB. With some minor code modifications, we can use the same example to visualise vector embeddings for a search term.The notebook file used in this article is available on GitHub.In a great article, the author demonstrates how to visualise vector embeddings using several technologies. We can use a previous OpenAI example dataset, simplify the code, and use Plotly Express to render a similar visualisation. Let's see how.As described in a previous article, we'll follow the instructions to create a Notebook.First, we'll install the OpenAI library:Next, we'll specify our embedding model:Next, we'll set our OpenAI API Key:Now we'll add a few more libraries:and imports:We'll now download a CSV file from OpenAI that contains text and embeddings related to the Winter Olympics 2022:Now we'll read the file into a Dataframe and convert the data to a NumPy Array:Our search term is "curling gold medal", and we'll get the vector embeddings for this from OpenAI:Now we'll find and store the Euclidean Distance between the search term and the vector embeddings we previously loaded:and scale the values between 0 and 1, then store them, as follows:Finally, we'll create a t-SNE model and plot the data using Plotly Express:The output should be as shown in Figure 1.Colours specify similarity to the search term. In this case, we can see red areas on the plot that are closer and blue areas that are further away.Data visualisation can be used to gain insights into the distribution of data, as seen in a previous article. In this article, we saw how to use vector embeddings and a search term to create a t-SNE model and visualise it using Plotly Express. This simple example showed how to use data visualisation to identify patterns and trends.Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse Be Hai Nguyen - Jul 9 Asmae El-Ghezzaz - Jun 18 Mannu - Jul 8 Thomas Hansen - Jul 6 Once suspended, singlestore will not be able to comment or publish posts until their suspension is removed. Once unsuspended, singlestore will be able to comment and publish posts again. Once unpublished, all posts by singlestore will become hidden and only accessible to themselves. If singlestore is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to Akmal Chaudhri. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag singlestore: singlestore consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging singlestore will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Quick tip: Visualise OpenAI Vector Embeddings using Plotly Express

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×