Skip to main content

Understanding Vector Memory

Think of vector memory as your agent’s superpower! It transforms text into mathematical representations that capture meaning, enabling your agent to find semantically similar content even when the exact words don’t match.
Flexible & Powerful: Choose from multiple storage providers (Meilisearch, PostgreSQL + pgvector) and embedding providers (OpenAI, Gemini, Cohere, Ollama) to fit your needs!

Semantic Search

Find content by meaning, not just keywords

Efficient Retrieval

Lightning-fast similarity searches at scale

Multiple Providers

Support for various storage and embedding providers

Context Augmentation

Enhance responses with relevant knowledge

Setting Up Vector Memory

Let’s get your vector memory up and running with Meilisearch! It’s the perfect balance of speed, simplicity, and power.

Quick Setup with Meilisearch

Configure vector memory with Meilisearch in your .env file:
.env
Alternative option: You can also use PostgreSQL + pgvector for production-scale vector similarity search. See the complete configuration reference below for setup details.

Database Setup

Terminal

Using Vector Memory in Agents

Your agents now have built-in access to vector memory! Use the convenient $this->vector() or $this->rag() methods directly within your agent.New! These methods are now public, so you can also access them externally for testing: $agent->vector()->addDocument(...)

Storing Documents in Your Agent

Using Vector Memory in an Agent
Both $this->vector() and $this->rag() return a proxy that automatically injects your agent class. No need to pass agent names anymore!Simplified API: Use simple strings for basic operations, or arrays for full control with progressive disclosure!

Direct VectorMemoryManager Access

For advanced use cases outside of agent contexts, you can still use the VectorMemoryManager directly:
Direct VectorMemoryManager Usage

Progressive Disclosure API

Smart API Design: Start simple, add complexity only when needed!
Progressive API Examples

Document Chunking Configuration

Pro tip: Adjust chunk sizes based on your content type. Smaller chunks for FAQs, larger for narrative content!
config/vizra-adk.php

Searching Vector Memory

Here’s where the magic happens! Watch your agent find exactly what it needs, even when users ask questions in completely different words.

Semantic Search in Agents

Semantic Search in Agent

RAG Context Generation

RAG (Retrieval-Augmented Generation) combines the power of vector search with LLM generation for incredibly accurate responses!
Generate RAG Context in Agent

Building RAG-Powered Agents

Transform your agents into knowledge powerhouses! Here’s a complete example of a RAG-enabled documentation assistant.

Complete RAG Agent Example

Documentation Assistant with RAG

RAG Configuration

config/vizra-adk.php

Embedding Providers

OpenAI (Default)

.env

Supported Models

  • text-embedding-3-small (1536 dims)
  • text-embedding-3-large (3072 dims)
  • text-embedding-ada-002 (1536 dims)

Custom Provider

Implement EmbeddingProviderInterface to add custom embedding providers

Vector Memory Management

Keep your vector memory clean and efficient! Here’s how to manage, monitor, and optimize your knowledge base.

Managing Memories

Memory Management in Agents

Creating Tools for Vector Operations

Vector Memory Tools

Using the VectorMemory Model

Direct Model Access

Vector Storage Drivers

PostgreSQL with pgvector

High-performance vector similarity search with native PostgreSQL integration.
Setup

Meilisearch

Lightning-fast, typo-tolerant search engine with built-in vector support.
Setup
Fallback Behavior - When neither pgvector nor Meilisearch are available, Vizra ADK automatically falls back to cosine similarity calculation using your database. This works with any driver but is best for development or small datasets.

Complete Configuration Reference

Here’s a complete reference for all vector memory configuration options available in Vizra ADK!
config/vizra-adk.php

Console Commands

Powerful CLI tools to manage your vector memory right from the terminal!

Available Commands

Terminal

Vector Memory Best Practices

Organization

  • Use namespaces to organize content
  • Include descriptive metadata
  • Use content hashing to avoid duplicates

Optimization

  • Choose appropriate chunk sizes
  • Monitor token counts for costs
  • Use pgvector for production

Strategy

  • Match chunking to content type
  • Select models for your use case
  • Clean up old memories regularly

Remember

  • Test similarity thresholds
  • Balance context size vs accuracy
  • Consider hybrid search approaches

Next: Evaluations

Learn about testing and evaluating agents

Sessions & Memory

Review memory management