Vector Stores

A vector store is a specialized data store that indexes and retrieves data by meaning (semantic similarity) rather than exact keyword matches.

About Vector Stores

Vector Store
  • What it stores:Vectors (also called embeddings), which are numeric representations of content such as documents, passages, chat messages, code, or images, plus metadata (ID, timestamp, source, and so on).
  • What it does: Supports fast similarity search (and often hybrid search), so you can retrieve the most relevant pieces of information from the provided data.
Vector Store in Generative AI
  • Powers retrieval-augmented generation (RAG): Embed knowledge sources with a vector store, retrieve the most similar chunks at query time, and then provide them to the LLM as grounded context.
  • Grounds the responses: Improves relevance of retrieved information and reduces chances of using hallucinated information by grounding responses in retrieved enterprise content.
Example Use cases
  • Finding relevant documents that match a user's questions.
  • Powering contextual search in chatbots.
Example workflow
  1. Chunk a PDF into paragraphs.
  2. Create an embedding vector for each paragraph.
  3. Store vectors + paragraph text + metadata in the vector store.
  4. When a user asks a question, embed the question and retrieve the closest paragraphs to include as context for the model.

Client Setup

from oci_openai import OciOpenAI, OciSessionAuth

cp_client = OciOpenAI(
            base_url="https://generativeai.<region-code>.oci.oraclecloud.com/20231130/openai/v1",
            auth=OciSessionAuth(profile_name="DEFAULT"),
            compartment_id="ocid1.compartment.oc1..aaaaaaaaexample",
        )