Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab VeloxTrend Ultrarix Capital Partners Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Our 15 AI experts built the most comprehensive, practical, 90+ lesson courses to master AI Engineering - we have pathways for any experience at Towards AI Academy. Cohorts still open - use COHORT10 for 10% off.

Publication

How Vector Similarity Search Powers RAG and Agentic AI in Enterprise Applications
Latest   Machine Learning

How Vector Similarity Search Powers RAG and Agentic AI in Enterprise Applications

Last Updated on November 11, 2025 by Editorial Team

Author(s): Kapil Deshmukh

Originally published on Towards AI.

From embeddings to retrieval: mastering vector similarity search for next-gen enterprise AI applications.

How Vector Similarity Search Powers RAG and Agentic AI in Enterprise Applications
Photo by Ecliptic Graphic on Unsplash

🚀 Introduction

If you’ve ever asked ChatGPT a question like “What animal likes milk?” and received a precise answer, you’ve already seen vector similarity search in action.

Behind the scenes, AI systems rely on embeddings (numerical representations of text) and vector databases to find the most relevant information. This is the backbone of Retrieval-Augmented Generation (RAG), agentic AI, and modern enterprise AI chatbots.

In this article, we’ll explore:

  • How embeddings transform text into vectors.
  • The role of similarity metrics (cosine, Euclidean, dot product).
  • How vector databases like FAISS, Pinecone, and Weaviate enable lightning-fast search.
  • A hands-on Python demo with OpenAI embeddings.

🧠 What Are Embeddings?

Think of embeddings as the language of meaning for AI.

  • Text is converted into high-dimensional vectors (e.g., 1536 dimensions for OpenAI).
  • Similar concepts produce vectors that are close together.

Example:

"cat" → [0.8, 0.1, 0.2, …]

"dog" → [0.7, 0.15, 0.25, …]

"car" → [-0.2, 0.9, -0.1, …]

Here, cat and dog vectors are close, while car is far away.

🏗️ The Role of Vector Databases

When enterprises deal with millions of documents, they can’t compare every vector manually.
That’s where vector databases like FAISS, Pinecone, Weaviate, and Qdrant come into picture.

They:

  • Store embeddings efficiently.
  • Support Approximate Nearest Neighbor (ANN) search for speed.
  • Provide APIs to integrate with LLMs for RAG pipelines.

🧑‍💻 Hands-On Demo with Python

Let’s see how embeddings + similarity search work in practice.

# Install dependencies:
# pip install openai faiss-cpu

import openai, faiss, numpy as np
openai.api_key = "YOUR_OPENAI_API_KEY"

docs = [
"Cats are small domesticated animals that like milk.",
"Dogs are loyal and bark at strangers.",
"Cars are used for transportation on roads."
]

# Get embeddings from OpenAI
def embed(text, model="text-embedding-3-small"):
resp = openai.embeddings.create(input=[text], model=model)
return np.array(resp.data[0].embedding, dtype=np.float32)

doc_embeddings = [embed(d) for d in docs]
dim = len(doc_embeddings[0])

# Build FAISS index (cosine)
index = faiss.IndexFlatIP(dim)
normed_docs = np.array([v/np.linalg.norm(v) for v in doc_embeddings])
index.add(normed_docs)

# Query
query = "What animal likes milk?"
q_emb = embed(query) / np.linalg.norm(embed(query))

# Search
scores, idx = index.search(np.array([q_emb]), 2)

print("\n🔹 Results:")
for i, doc_id in enumerate(idx[0]):
print(f"Rank {i+1}: {docs[doc_id]} (score={scores[0][i]:.4f})")

Expected Output

🔹 Results:
Rank 1: Cats are small domesticated animals that like milk. (score ~0.9)
Rank 2: Dogs are loyal and bark at strangers. (score ~0.6)

🏆 Key Takeaways

  1. Embeddings transform text into machine-understandable vectors.
  2. Cosine similarity is the go-to metric for semantic search in AI apps.
  3. Vector databases like Pinecone and FAISS make retrieval fast at scale.
  4. Together, they power RAG pipelines, chatbots, and agentic AI workflows in enterprise environments.

The future of enterprise AI isn’t just about large language models.
It’s about combining LLMs with
retrieval, reasoning, and tool orchestration — and at the heart of it all lies vector similarity search.

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI


Take our 90+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Towards AI has published Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!


Discover Your Dream AI Career at Towards AI Jobs

Towards AI has built a jobs board tailored specifically to Machine Learning and Data Science Jobs and Skills. Our software searches for live AI jobs each hour, labels and categorises them and makes them easily searchable. Explore over 40,000 live jobs today with Towards AI Jobs!

Note: Content contains the views of the contributing authors and not Towards AI.