Oracle AI Vector Search FAQ

FAQ topics

General questions

What is a vector?

A vector is a numerical representation of text, images, audio, or video that encodes the features/semantic meaning of the data, rather than the actual contents such as the underlying words or pixels. A vector is a list of numerical values, known as dimensions, with a specified format.

How many vector dimensions are supported?

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

What number formats are supported for vectors?

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

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 KB in size. A vector with 1,024 dimensions and the FLOAT32 (4 byte) format is 4 KB in size.

How are vectors created?

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

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 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, such as various sentence transformers, can be found on Hugging Face and similar sites. These models can be converted to ONNX to run in the database with AI Vector Search. Additionally, 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.

What operations are supported on vectors?

There are multiple mathematical operations supported on vectors, but the most important operation is the VECTOR_DISTANCE() SQL function, which finds the mathematical distance between two vectors based on distance formula selected. There are many distance formulas supported by Oracle AI Vector Search, including Euclidean distance, cosine similarity, and Hamming distance. The choice of distance function is typically driven by the embedding model used to generate the vectors.

How are vectors used in similarity search?

All types of 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 simply 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 the 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, etc. For instance, the following query can be used to find the top 10 matching products by photo for products that are manufactured within the state of California.

SELECT Product.name, Product.photo, Manufacturer.name
FROM Product p JOIN Manufacturer m ON (p.mfr_id = m.id)
WHERE Manufacturer.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 value-based range scans. Vector indexes, on the other hand, are designed to find the top K most similar matches based on semantic similarity instead of exactly matching values. For instance, a vector index can be used to find the top K words that are 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 within a column.

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 a variety of 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 can be used in the well-known retrieval-augmented generation (RAG) workflow to help enhance the accuracy and contextual relevance of natural language conversations with GenAI large language model (LLMs). 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 on to the LLM so it can generate an informed answer based on both its own general knowledge and the specialized knowledge from the vector store.

Which LLMs does AI Vector Search work with?

AI Vector Search can be used for RAG with open source LLMs such as Llama2 or Llama3, as well as LLMs from providers such as OpenAI and Cohere.

Does AI Vector Search support LangChain?

AI Vector Search is integrated with LangChain, which is a very popular open source framework for building RAG-based solutions.

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

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