Lesson 1 of 4 Embeddings

Choosing Which Columns to Embed

This lesson explains which columns to include in embedding text, which to keep as filters and how change frequency affects the choice.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify columns that make good embedding text.
  • Explain why numbers and codes are better used as filters.
  • Describe how to detect when embedded text has changed.

What makes good embedding text

Embeddings capture meaning, so the text should describe what users will search for in natural language: product names and descriptions, article titles and bodies, review text, ticket summaries or policy clauses. Short fields such as a name alone produce weak embeddings, so several columns are concatenated with labels that give the model context.

SELECT ProductID,
       CONCAT(N'Product: ', p.Name,
              N'. Category: ', c.Name,
              N'. Brand: ', p.Brand,
              N'. Description: ', p.Description) AS EmbeddingText
FROM Catalog.Product AS p
JOIN Catalog.Category AS c ON c.CategoryID = p.CategoryID;
Scenario questions

Building the embedding text

Exam skills 3.1.4

Choose the embedding text for each case.

Log in to try this activity Interactive activities are free with an account.

What to keep out

Identifiers, prices, quantities, dates, stock levels and status codes carry little semantic meaning and change often, so they work poorly in embeddings: 'under 200 dollars' is not reliably close to a price of 189. They stay as columns and are applied as exact filters in the WHERE clause together with vector search. The following table summarizes common choices.

DataEmbed?Why
Name, title, description, body textYesCarries the meaning users search for
Category and brand namesOften, as labelled contextAdds meaning to short text; also filterable
Price, quantity, dates, ratingsNo; filter insteadNumbers need exact comparisons
IDs, SKUs, codesNo; use full-text or equalityExact tokens without semantic meaning
Personal or confidential dataAvoidSent to the model provider and partly recoverable from vectors

Change frequency and freshness

Every change to embedded text requires a new embedding, which costs a model call. Including volatile columns, such as stock levels, would force constant re-embedding for no search benefit. Storing a hash of the embedding text (for example HASHBYTES('SHA2_256', EmbeddingText)) next to the vector lets a maintenance job skip rows whose text has not changed. When several kinds of question target different content, separate embeddings, such as one for descriptions and one for reviews, can be stored and searched separately.

True or false

Freshness and cost

Exam skills 3.1.4 · 3.1.3

Decide whether each statement about embedding freshness is true.

Log in to try this activity Interactive activities are free with an account.
Worked example

What to embed for product search

A product table has ProductID, SKU, Name, Description, Category, Price, StockQty and LastRestocked. Customers ask questions such as 'warm waterproof boots for winter hiking under 150'. Which columns should the embedding include?

Embed a labelled combination of Name, Category and Description, and apply 'under 150' as WHERE Price < 150 (with the price extracted by the application or a model). SKU is better served by full-text or equality search, and StockQty and LastRestocked change constantly without adding meaning, so including them would cause unnecessary re-embedding.

Check yourself

Why are not prices good embedding content?

Show answer

Numbers carry little semantic meaning in embeddings, so price constraints are applied as exact WHERE filters.

Exam Tips

Remember for the exam

  • Embed descriptive text with labels; filter numbers and dates with WHERE.
  • Exact codes and IDs: full-text or equality, not embeddings.
  • Avoid embedding volatile or sensitive columns.
  • Store a hash of the embedded text to detect when re-embedding is needed.