Oracle AI Vector Search FAQ

FAQ topics

General questions

What is a vector?

A vector is a mathematical representation of text, images, audio, or video that encodes the features or semantic meaning of the data rather than the actual contents, such as the underlying words or pixels. A vector consists of a list of numerical values, known as dimensions, and can be used for artificial intelligence (AI) operations.

How are vectors created?

Vectors are created from different types of input data (text, images, audio, video, and other data) by deep learning models known as embedding models. You can create vectors outside the database using embedding models, an embedding service, or create them within the database using ONNX embedding models via the VECTOR_EMBEDDING() SQL function.

What dimension formats are supported for vectors?

Oracle AI Vector Search supports the BINARY, INT8, FLOAT32, and FLOAT64 formats.

How many vector dimensions are supported?

Oracle AI Vector Search supports vectors with up to 65,535 dimensions.

How big are vectors?

The size of a vector is the product of the number of dimensions and the size of each dimension.

For example, a vector with 2,048 dimensions and the INT8 (1 byte) format is 2 kilobytes in size, and a vector with 1,024 dimensions and the FLOAT32 (4 bytes) format is 4 kilobytes in size.

Does AI Vector Search support sparse vectors?

Oracle AI Vector Search supports sparse vectors, which typically have many dimensions, but only a few dimensions have non-zero values. For a given document, the non-zero dimension values in the vector correspond to the keywords (and their variations) that appear in that document.

Which embedding models does AI Vector Search work with?

AI Vector Search should work with any valid embedding model that generates vectors with one of the supported dimension formats and 65,535 or fewer dimensions.

Which embedding models should I consider using, and where can I get them?

The choice of embedding model depends on many factors, such as the nature of your data, the performance metrics you prioritize, and the cost you’re willing to pay. Free, open source embedding models, including various sentence transformers, can be found on Hugging Face and similar sites. These models can be converted to ONNX to generate embeddings in the database with AI Vector Search. A popular source for the best text embedding models is the MTEB Leaderboard hosted by Hugging Face. You can also go to established model providers, such as OpenAI and Cohere.

Does AI Vector Search support image embedding models?

AI Vector Search supports vectors generated from all embedding models, regardless of whether the models are for text, images, audio, video, or other data. Oracle Database also includes ONNX-precompiled embedding models for performing image-based distance operations with AI Vector Search.

What operations are supported on vectors?

There are multiple mathematical operations supported on vectors. The most critical operation is the VECTOR_DISTANCE() SQL function, which finds the mathematical distance between two vectors based on the selected distance formula. There are many distance formulas supported by Oracle AI Vector Search, including Euclidean, Euclidean Squared, Cosine Similarity, Dot Product, Manhattan, Jaccard, and Hamming. The choice of distance function is typically driven by the embedding model used to generate the vectors, However, the default distance metric in Oracle Database 23ai is Cosine Similarity.

How are vectors used in similarity search?

All vectors share the same property: the more similar two entities are, the smaller the mathematical distance between them. For instance, the vectors for “apple” and “orange” are closer together than the vectors for “apple” and “dog.” This property of vectors allows them to be used to search data by semantic similarity.

How is AI Vector Search performed using SQL?

There are simple and intuitive SQL extensions that allow AI Vector Search to be easily incorporated within your applications. Since vector distance is a measure of similarity, AI Vector Search involves sorting the set of candidate vectors based on their distance from a search vector and returning the top K closest matches. For example, the query below finds the top 10 products whose photos most closely match a user’s search photo:

SELECT product_name, product_photo
FROM product
ORDER BY VECTOR_DISTANCE(product_photo_vector, :search_photo_vector)
FETCH FIRST 10 ROWS ONLY;

How can I use AI Vector Search in complex queries involving business data?

AI Vector Search can be used in sophisticated queries involving filters, joins, aggregations, group by, and other elements. For instance, the following query can be used to find the top 10 matching products manufactured in California based on a photo uploaded by a user.

SELECT p.name, p.photo, m.name
FROM product p
JOIN manufacturer m ON (p.mfr_id = m.id)
WHERE m.state = 'CA'
ORDER BY VECTOR_DISTANCE(product_photo_vector, :search_photo_vector)
FETCH FIRST 10 ROWS ONLY;

What are vector indexes, and how are they different from traditional database indexes?

Traditional database indexes are used to accelerate searches based on matching values. For instance, a B-tree index speeds up value-based lookups and range scans. Vector indexes, on the other hand, are designed to find the top K most similar matches based on semantic similarity instead of precisely matching values. A vector index can be used to find the top K words most similar in meaning to “apple” in a corpus of existing words. Using a vector index results in an approximate search that trades off some search accuracy for up to 100X greater performance since it avoids examining every single vector entry within a column.

What are in-memory neighbor graph vector indexes?

In-memory neighbor graph vector indexes are graph-based memory resident indexes. The vertices of the graph represent vectors, and the edges between the vertices represent the similarity between the vectors. Oracle AI Vector Search supports Hierarchical Navigable Small World (HNSW) type in-memory neighbor graph vector indexes. HNSW indexes are structured using principles from small world networks and layered hierarchical organization, making them extremely fast and accurate for similarity search.

What are neighbor partitioned vector indexes?

Oracle AI Vector Search supports Inverted File Flat (IVF) type neighbor partitioned vector indexes. Neighbor partitioned vector indexes are disk-based vector indexes where the vectors are clustered into table partitions based on similarity. They are an efficient scale-out index with fast and seamless transactional support, allowing you to balance high-quality search with reasonable speed. They are designed to accommodate unlimited data sizes, by virtue of the fact that they are not memory dependent.

What are hybrid vector indexes, and how are they different from traditional database indexes?

Hybrid vector indexes are a new type of vector index that allows users to easily index and query their documents using a combination of full-text search and semantic vector search to achieve higher-quality search results. They support a unified query API that allows users to run textual queries, vector similarity queries, or hybrid queries that leverage both approaches.

What programming languages can be used to develop AI Vector Search applications?

In addition to SQL and PL/SQL, AI Vector Search applications can be built in various programming languages. AI Vector Search includes native driver support for vectors in popular languages, such as Java, Python, JavaScript, and C#.

What role does AI Vector Search play in generative AI?

AI Vector Search is often part of a retrieval-augmented generation (RAG) workflow. It provides additional inputs needed to fine-tune the response from a GenAI large language model (LLM).

When combined with RAG, a user’s question is first converted into a vector and then mapped to the most relevant documents within the database via AI Vector Search. Then, the user’s question and the supporting relevant documents are passed to the LLM, which generates an informed answer based on its general knowledge and the specialized knowledge from the database.

Which LLMs does AI Vector Search work with?

AI Vector Search can be used for RAG with any LLM, including open source models, such as Llama3 and Mistral, as well as proprietary models from providers like OpenAI and Cohere. Additionally, specialized PL/SQL APIs are available for seamless integration between AI Vector Search and LLMs for RAG.

Does AI Vector Search support AI integration frameworks and chains?

AI Vector Search is integrated with LangChain and LlamaIndex. These frameworks can help integrate private and public data for large language model applications.

What are the benefits of retrieval-augmented generation (RAG)?

Retrieval-augmented generation (RAG) plays a pivotal role in generative AI (GenAI), offering significant advantages to GenAI applications. The following are just three compelling reasons why it is paramount to integrate RAG into your GenAI setup:

  1. Minimize hallucinations: Large language models (LLMs) may generate inaccurate or irrelevant responses if they lack substantial training on prompts. Retraining LLMs to align with desired responses often incurs substantial costs.
  2. Safeguarding confidentiality: LLMs are trained on publicly available information from the internet—they do not know about your company-specific data. You probably do not want to send your company-specific information across the internet, as you are giving away your private information to a third party. Instead, consider keeping your enterprise data within your realm using local LLMs within your data center or cloud tenancy.
  3. Up-to-date information: LLMs are trained up to a specific date; newer events or facts are unknown. Using RAG, the LLM can provide responses based on up-to-date information from a vector database supplied via the prompt. This means the LLM has the benefit of the latest data from your company without needing to train the LLM on your data.

How can I scale AI Vector Search to meet the growing needs of my application?

Oracle’s extensive scalability mechanisms—such as Parallel Execution, Partitioning, Real Application Clusters (Oracle RAC), Sharding, and Exadata—can scale up AI Vector Search to virtually any data size and number of users.

Are there any benefits in running AI Vector Search on Oracle Exadata?

Oracle’s extensive scalability mechanisms—such as Parallel Execution, Partitioning, Oracle Real Application Clusters (Oracle RAC), Sharding, and Exadata—can scale up AI Vector Search to virtually any data size and number of users. Oracle Exadata also includes AI Smart Scan, which offloads AI Vector Search query operations to the Exadata Storage Servers for unparalleled query performance.

How does Oracle provide data security for vectors?

Oracle AI Vector Search integrates seamlessly with Oracle's industry-leading database security features to reduce risk and simplify compliance. Organizations can secure their vector data by leveraging robust tools, such as encryption, data masking, privileged user access controls, activity monitoring, and auditing while taking full advantage of advanced AI search capabilities. In-database features, such as Database Vault and Virtual Private Database, help secure vector data and ensure that only users with the appropriate privileges can access it.

This means that Oracle AI Vector Search can significantly reduce the footprint of a company’s vector infrastructure. A single Oracle Database can address the needs of many different users with different access permissions and authorization without needing to duplicate data or incur any additional management overhead, as is often the case with other vector databases.

How does Oracle provide high-availability and disaster recovery capabilities for vectors?

Vectors in Oracle Database are first-class database datatypes. This means vectors implicitly inherit all the innovative features and capabilities that make Oracle the leading enterprise database in the world. High Availability (HA) is provided by running similarity searches on Oracle RAC or Oracle Globally Distributed Database (Sharding). Data Guard, Active Data Guard, and Oracle GoldenGate can all automatically provide disaster recovery.

Oracle Chatbot
Disconnected