Session
The Cosine Similarity Math: Visualizing Embeddings and Retrieval with BigQuery and Gemini
Retrieval-Augmented Generation (RAG) has quickly become one of the most practical approaches for building AI applications, yet many developers treat it as a “black box.” In this talk, I peel back the layers and dive into the math and mechanics that make RAG work.
I begin with a brief overview of RAG and then focus on its two core components: embeddings stored in a vector database and the retrieval of relevant data using cosine similarity. I explain how text is transformed into embeddings, which are arrays of numbers that capture semantic meaning, and compare different methods of generating embeddings, highlighting why vector representations are essential in this context.
Next, I explore cosine similarity as the retrieval mechanism. By plotting embeddings in a 3D graph, I show how measuring the angle (cos θ) between vectors determines relevance.
Finally, I walk through a live coding demo to build a simple RAG pipeline, showing how embeddings are stored in a vector database and retrieved in real time.
Dev J. Shah
SWE @TribalScale, GenAI Evangelist (Blogger, Speaker) || 4x Multi-Cloud Certified || Software Engineering, AI Engineering || Linux, Cloud, DevOps
Toronto, Canada
Links
Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.
Jump to top