1. Fundamentals: Vectors & Embeddings
What is a Vector?
In the context of computer science and data, a vector is simply an ordered list of numbers (e.g., [1.2, -0.5, 0.8]). In mathematics/physics, it represents magnitude and direction, but in AI, it is primarily a way to represent features or coordinates in a multi-dimensional space.
What are Embeddings?
An EmbeddingA dense numerical vector representation of text (or other data) that captures semantic meaning. Semantically similar texts have embeddings that are geometrically close. Embeddings power semantic… is a specific type of vector used to represent “real world” objects (text, images, users, products) in a form that machines can understand.
- Transformation: AI models (like GPT) take complex data (e.g., the word “Apple”) and transform it into a long list of numbers (e.g., a 1536-dimensional vector).
- Semantic Meaning: Crucially, this transformation preserves meaning.
- The vector for “Apple” will be numerically closer to “Banana” (both fruits) than to “Car” (vehicle).
- The vector for “King” minus “Man” plus “Woman” results in a vector very close to “Queen”.
Importance for AI
Embeddings are the foundation of modern “Semantic SearchA search technique that finds results based on meaning and intent rather than exact keyword matches. Semantic search converts queries and documents into embeddings and retrieves the most semantically…” and RAGA technique that enhances LLM responses by retrieving relevant documents from an external knowledge base and including them in the prompt context. RAG reduces hallucinations and enables LLMs to… (Retrieval Augmented Generation).
- Traditional Search: Matches keywords (
WHERE name ILIKE '%apple%'). Fails if user searches for “Fruit”. - Vector Search: Matches meaning (
ORDER BY embedding <-> query_embedding). Successfully finds “Apple” when searching for “Fruit” because their vectors are close in the multi-dimensional space. - Memory: They allow AI agents to “remember” vast amounts of data by retrieving only the most relevant snippets (context) based on the semantic similarity to the user’s current question.
2. OCA Module: field_vector
Purpose
The field_vector module (part of OCA/server-tools) introduces a native Vector Field type to the Odoo framework. It was originally introduced for Odoo 16.0 by Laurent Mignon (Acsone) via PR #3251.
- Native Integration: It allows developers to define
vectorfields on Odoo models just likeCharorIntegerfields. - pgvector Backbone: It leverages the pgvector PostgreSQL extension to store these vectors efficiently.
- No External DB: It eliminates the need for a separate Vector DatabaseA database optimized for storing and querying high-dimensional embedding vectors. Used in RAG and semantic search to find documents or data points most similar to a query vector. Examples: Pinecone,… (like Pinecone).
Note on Odoo 19.0
We worked on the migration of that module to Odoo 19.0, see PR #3430.