Vector Stores
Vector stores power the Retrieval-Augmented Generation (RAG) pipeline in the MATIH Platform. They store vector embeddings of schema metadata, SQL query examples, business terminology, and documentation, enabling the AI Service to retrieve relevant context when generating SQL and answering questions.
Vector Store Options
| Technology | Use Case | Deployment |
|---|---|---|
| Qdrant | Production vector search | Kubernetes (Helm chart) |
| LanceDB | Development and testing | Embedded (no server) |
Qdrant
Qdrant is the production vector database:
| Aspect | Details |
|---|---|
| Index type | HNSW (Hierarchical Navigable Small World) |
| Distance metric | Cosine similarity |
| Filtering | Payload-based filtering with tenant ID |
| API | REST and gRPC |
| Multi-tenancy | Tenant ID in payload metadata, filtered at query time |
Embedding Sources
The RAG pipeline indexes the following content as vector embeddings:
| Source | Indexed Content | Update Frequency |
|---|---|---|
| Catalog metadata | Table names, column names, descriptions, data types | On schema change |
| Query examples | Successful SQL queries with their natural language questions | After each successful query |
| Business terms | Ontology definitions, term relationships | On ontology update |
| Semantic model | Metric definitions, dimension descriptions | On model publish |
| Documentation | Platform and data documentation | On documentation update |
RAG Query Flow
User Question: "What was revenue last quarter?"
|
v
Embedding Model: Convert question to vector
|
v
Qdrant: Search for similar vectors
| Filter: tenant_id = "acme-corp"
| Top-K: 5 most similar results
|
v
Retrieved Context:
- Table: orders (columns: amount, order_date, customer_id)
- Similar query: "SELECT SUM(amount) FROM orders WHERE ..."
- Metric: revenue = SUM(orders.amount)
|
v
SQLAgent: Generate SQL using retrieved contextCollection Structure
| Collection | Content | Embedding Dimension |
|---|---|---|
schema_metadata | Table and column descriptions | 1536 |
query_examples | Question-SQL pairs | 1536 |
business_terms | Ontology definitions | 1536 |
semantic_models | Metric definitions | 1536 |
Each vector entry includes a payload with tenant ID, creation timestamp, and source metadata.
LanceDB (Development)
LanceDB provides an embedded vector store for development:
| Aspect | Details |
|---|---|
| Deployment | Embedded in AI Service process |
| Storage | Local filesystem |
| Index | IVF-PQ for approximate search |
| Multi-tenancy | Separate tables per tenant |
LanceDB requires no additional infrastructure, making it suitable for local development and testing.
Related Pages
- Agent Flow -- RAG in the agent pipeline
- Graph Stores -- Knowledge graph storage
- ML Infrastructure -- AI technology stack