[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3
SEQ. 4
Vector Databases Deep Dive
Choosing and Using Vector Databases
Vector databases are the backbone of agent long-term memory. They store embeddings (numerical representations of text) and enable similarity search.
Vector Database Comparison
| Database | Type | Max Vectors | Unique Strength | Best For |
|---|---|---|---|---|
| Pinecone | Managed SaaS | Billions | Zero-ops, fast scaling | Production, startups |
| Weaviate | Open + Managed | Hundreds of millions | Built-in vectorization | Full-stack vector apps |
| Chroma | Open-source | Millions | Simple API, embedded mode | Prototyping, local dev |
| Qdrant | Open-source | Billions | Rust performance, filtering | High-performance search |
| pgvector | PostgreSQL extension | Millions | Uses existing Postgres | Adding vectors to existing apps |
Key Concepts
- Embeddings: Convert text to a fixed-length vector (e.g., 1536 dimensions). Similar text produces similar vectors.
- Similarity Search: Find the K nearest vectors to a query vector. Common metrics: cosine similarity, dot product, L2 distance.
- Metadata Filtering: Combine vector search with traditional filters (e.g., "find similar docs WHERE category = 'legal'").
- Namespaces/Collections: Partition vectors by tenant, project, or type for isolation and performance.
Integration Pattern
// Agent Memory with Vector DB:
async function rememberAndRecall(agent, userMessage) {
// 1. Search for relevant memories
const memories = await vectorDB.query({
vector: await embed(userMessage),
topK: 5,
filter: { userId: user.id }
});
// 2. Inject memories into context
const context = memories.map(m => m.text).join('\n');
// 3. Generate response with memory context
const response = await llm.generate({
system: `You have access to past conversations: ${context}`,
user: userMessage
});
// 4. Store this interaction as new memory
await vectorDB.upsert({
id: generateId(),
vector: await embed(userMessage + response),
metadata: { userId: user.id, timestamp: Date.now() }
});
return response;
}
💡 Key Insight: Start with Chroma for prototyping (runs in-process, no server needed), then migrate to Pinecone or Qdrant for production. The API patterns are similar enough that migration is straightforward.
⌨ HANDS-ON LABStand Up a Local Vector Store
⭐ +150 XPYour agent needs long-term memory today, not after a procurement cycle. Install Chroma, insert two memories, and run a similarity query - all locally.
1Install the chromadb package from PyPI.
2Add two documents to a collection with a one-liner (python -c).
3Query the collection for the nearest memory to 'UI theme preferences'.
OBJECTIVE 1 / 3 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 2
What is the recommended vector database for prototyping and local development?
Pinecone
Chroma (simple API, runs embedded, no server required)
Amazon Neptune
MongoDB