LyraLearn AI Learning Platform
Exams
← Module 4 Β· Embeddings
🎧 Listen

Embeddings in Practice

Knowing what an embedding is matters less than running an embedding pipeline that stays correct in production. Most failures aren't exotic β€” they're chunking that's too coarse, a column that doesn't match the model, or stale vectors after a content edit. This lesson is the operational checklist for embeddings in a .NET / SQL Server system.

A circular pipeline of chunking, embedding, storing, and retrieving, with a re-embed loop triggered whenever the source text changes.

Chunk before you embed

You almost never embed a whole document. A model produces one vector per input, so a 30-page policy collapsed into a single vector becomes a blurry average that matches nothing well. Instead you chunk: split the document into passages and embed each one.

Guidelines that hold up in enterprise content:

Store vectors where you can query them

Store the vector next to the text it came from, in a column whose size exactly matches the model's dimensions. With SQL Server 2025:

CREATE TABLE LessonChunks (
    Id          INT IDENTITY PRIMARY KEY,
    LessonId    INT          NOT NULL,
    ChunkText   NVARCHAR(MAX) NOT NULL,
    Embedding   VECTOR(768)   NOT NULL   -- must equal the model's output size
);

If the model emits 768 numbers, the column must be VECTOR(768). A mismatch β€” VECTOR(1536) for a 768-dim model β€” fails at insert time, which is the good outcome; the bad outcome is silently storing vectors from two different models in one column, where distances become nonsense. Treat (model, dimension, column) as a single locked contract.

Know when to re-embed

Embeddings are a derived artifact: they go stale the moment their source changes. Re-embed when:

  1. The text changes β€” edit a lesson or policy paragraph, and that chunk's old vector now describes text that no longer exists. Re-embed just the affected chunks.
  2. The chunking strategy changes β€” new sizes or boundaries mean every vector must be rebuilt.
  3. The embedding model changes β€” the cardinal rule from the previous lesson: a new model puts vectors in a new space, so you must re-embed the entire corpus, not mix old and new.

Build the pipeline so re-embedding is routine β€” ideally triggered automatically whenever content is saved β€” rather than a scary one-off migration.

The whole loop, end to end

Putting it together, here is the LyraLearn pipeline and the shape of any production system:

  1. Ingest content and split it into chunks.
  2. Embed each chunk with the local nomic-embed-text model (768-dim).
  3. Store the vector in a VECTOR(768) column with its text and metadata.
  4. Retrieve at query time by embedding the question and running a VECTOR_DISTANCE cosine search for the nearest chunks.
  5. Re-embed whenever the text, chunking, or model changes.

Get those five steps right and embeddings stop being theory β€” they become the dependable retrieval layer under every RAG feature you build.

🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.