πŸ“š Understanding Embeddings and Vector Databases with Qdrant

Posted by:

|

On:

|

, , ,

🧠 What Are Embeddings?

  • Explain how text, images, audio, etc. are converted into vectors (mathematical representations)
  • Introduce the concept of semantic similarity using vector distance
  • Show why this matters (recall memory, search, retrieval, etc.)

πŸ“ Understanding Vector Sizes

  • Different embedding models produce different vector dimensions
    • mxbai-embed-large β†’ 1024
    • text-embedding-3-small β†’ 1536
    • all-MiniLM-L6-v2 β†’ 384
  • Qdrant needs you to declare this size when you create a collection
  • Mismatch = πŸ”₯ β€œBad request, dimension error”

πŸ§ͺ What Embedding Model Should You Use?

ModelDimensionsBest forNotes
mxbai-embed-large1024General memoryGreat with LLMs
text-embedding-3-small1536Short-form textOpenAI fallback
all-MiniLM-L6-v2384Lightweight useFast, decent

πŸ”§ How to Create an Embedding + Insert Into Qdrant

import { createClient } from '@qdrant/js-client-rest';
import { getEmbedding } from './embedding';

const client = new QdrantClient({ url: 'http://localhost:6333' });

await client.upsert('guardian_memories', {
  points: [
    {
      id: 'memory_001',
      vector: await getEmbedding('This is an example memory.'),
      payload: {
        source: 'BlogPost',
        tags: ['guardian', 'blog'],
        timestamp: new Date().toISOString(),
      },
    },
  ],
});
  • Your getEmbedding() function can call Ollama or an API
  • Your collection must match the vector size

🧷 Qdrant + Guardian

  • Qdrant is the long-term memory store
  • Guardian uses it for:
    • Similarity search
    • Memory retrieval per task
    • Contextual enrichment for LLM calls
  • Supabase handles metadata, Qdrant handles semantic recall

πŸ›  Common Problems

IssueCauseFix
Dimension mismatchVector size doesn’t match Qdrant collectionDouble-check the model you’re using
Service not foundQdrant not running / wrong portRestart Docker, check localhost:6333
Bad vector valuesNaNs or zero-vectorsNormalize inputs before embedding

🧭 Next Steps

  • Add a tag, source, or taskId to every memory
  • Use filter + vector search together
  • Log LLM decisions with addMemory() and classify them with runLLM()

Leave a Reply

Your email address will not be published. Required fields are marked *