Skip to content

Embeddings & Vectors

Embeddings are like creating a “fingerprint” for text that captures its meaning in numbers. Instead of searching for exact word matches, you can find content that means the same thing, even if it uses completely different words.

This is the secret behind smart search systems that understand what you’re really looking for.

Text being transformed into numerical vectors that represent meaning

Imagine you could represent the meaning of any text as a point in space. Similar meanings would be close together, while different meanings would be far apart. That’s exactly what embeddings do - they convert text into lists of numbers (vectors) that capture semantic meaning.

graph LR
    Text1["'The weather is sunny'"] --> Vector1["[0.2, 0.8, 0.1, ...]"]
    Text2["'It's a bright day'"] --> Vector2["[0.3, 0.7, 0.2, ...]"]
    Text3["'I love pizza'"] --> Vector3["[0.9, 0.1, 0.8, ...]"]
    
    Vector1 -.->|Similar| Vector2
    Vector1 -.->|Different| Vector3
    
    style Vector1 fill:#e1f5fe
    style Vector2 fill:#e1f5fe  
    style Vector3 fill:#ffebee

Traditional search looks for exact word matches. Embedding-based search understands meaning:

Search: “How to fix a broken website”

Finds: Documents containing exactly “fix”, “broken”, “website”

Misses:

  • “Troubleshooting site issues”
  • “Repairing web application problems”
  • “Website debugging guide”
  1. Text Input: You provide any text - a sentence, paragraph, or document

  2. AI Processing: An embedding model (like those in Ollama) analyzes the text

  3. Vector Creation: The model outputs a list of numbers representing the meaning

  4. Storage: These vectors can be stored and compared with other vectors

  5. Similarity Search: Find content with similar vector patterns

Vectors that are “close” in mathematical space represent similar meanings:

graph TD
    subgraph "Vector Space"
        A["'Dog'<br/>[0.8, 0.2, 0.1]"]
        B["'Puppy'<br/>[0.7, 0.3, 0.2]"]
        C["'Cat'<br/>[0.6, 0.4, 0.1]"]
        D["'Car'<br/>[0.1, 0.1, 0.9]"]
    end
    
    A -.->|Very Similar| B
    A -.->|Somewhat Similar| C
    A -.->|Very Different| D
    
    style A fill:#e8f5e8
    style B fill:#e8f5e8
    style C fill:#fff3e0
    style D fill:#ffebee

Instead of keyword matching, find documents by meaning:

  • Search “customer complaints” → finds “user feedback”, “service issues”, “client concerns”
  • Search “pricing information” → finds “cost details”, “fee structure”, “payment plans”

Find related articles or products:

  • User reads about “solar panels” → recommend “renewable energy”, “green technology”, “sustainable power”

Match questions to relevant answers:

  • Question: “How do I reset my password?”
  • Matches: “Password recovery”, “Account access issues”, “Login troubleshooting”

Find similar content even with different wording:

  • “The product is excellent” ≈ “This item is outstanding” ≈ “Great quality product”

Different models create different types of vectors:

Model TypeBest ForExample
General PurposeMost text contentnomic-embed-text
MultilingualMultiple languagesmultilingual-e5
Code-SpecificProgramming contentcode-embeddings
Domain-SpecificSpecialized fieldsbiomedical-embeddings
  1. Convert all your documents into embeddings
  2. Store embeddings with original text
  3. When users search, convert their query to embeddings
  4. Find documents with similar embeddings
  5. Return the most relevant original text
  • Similarity threshold: Only return results above a certain similarity score
  • Result ranking: Order results by how similar they are to the query
  • Metadata filtering: Combine embedding search with traditional filters
  • Detail: More complex vectors capture more meaning but take up more space.
  • Speed: Simpler vectors are faster to search but might miss subtle nuances.
  • Balance: Most standard models find a good middle ground for both.
  • Quality depends on the embedding model used
  • Some models better for specific types of content
  • May need fine-tuning for specialized domains

Embeddings transform how we search and understand text, making it possible to build truly intelligent document systems that understand meaning, not just words.