AI-ENGINEERING
    intermediate

    Embeddings & Vector Search

    AI Engineer path · lesson 71 of 124
    The idea
    An embedding turns each sentence into an arrow on a compass: sentences about the same thing point the same way. Searching is just 'which arrows point most like my question's arrow?'
    How to use
    In 'Semantic space': click a query button and adjust k to see top-k retrieval. Switch to 'Cosine geometry' and drag the θ slider to see how the angle between vectors determines the similarity score.
    Query:
    foodcodeweatherapple pie recipebanana smoothiechocolate cookiespython tutorialsorting algorithmreact componentsrain forecastsnow storm warningsunny afternoonquery
    Cosine similarity (ranked)
    1apple pie recipe0.99
    2banana smoothie0.98
    3chocolate cookies0.91
    4react components-0.28
    5snow storm warning-0.34
    6python tutorial-0.50
    7rain forecast-0.62
    8sorting algorithm-0.69
    9sunny afternoon-0.79
    Top-3 returned to the LLM as context.

    Key insight

    Meaning becomes geometry: similar text points the same direction, so retrieval is just “find the nearest vectors.” Cosine ranks by direction, top-k grabs the closest — that ranked list is exactly what RAG feeds the model.

    From text to a ranked result

    Sequence

    Order a semantic search, indexing first.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    6. 6Drop a step here
    6 pieces left to place

    Test your knowledge

    20 questions
    Question 1 of 20
    Score: 0

    What does an embedding represent?

    The short version

    An embedding turns each sentence into an arrow on a compass: sentences about the same thing point the same way. Searching is just "which arrows point most like my question's arrow?"

    In more depth

    Embeddings & Vector Search

    An embedding model maps text to a vector so semantically similar text points in similar directions (real embeddings typically run 100–10,000 dimensions: Cohere embed-english-light-3.0 is 384, CLIP 512, BERT base 768, OpenAI text-embedding-3-small 1536, text-embedding-3-large 3072). Cosine similarity = cos(angle) between two vectors — direction, not magnitude — and retrieval returns the top-k highest-cosine documents. At scale, an ANN index (HNSW/IVF) finds approximate neighbors fast.

    Interview Questions

    OpenAI
    Pinecone
    Google
    Pinecone
    Cohere
    Elastic
    Weaviate
    Cohere
    Databricks
    Pinecone
    Weaviate

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required