advanced

Embeddings

Represent text or objects as vectors whose distance approximates semantic similarity for retrieval tasks.

Embeddings are dense numeric vectors that represent text, images, or other objects so that semantic similarity approximates distance in vector space. A model maps "refund policy" and "money back guarantee" to nearby points even without shared keywords.

Typical flow: choose an embedding model (OpenAI, Cohere, open-source sentence transformers), chunk source content, batch-encode offline or on write, store vectors with metadata (source id, tenant, ACL), and query by encoding the user question and finding nearest neighbors.

| Concern | Implication | |---------|-------------| | Model version | Re-embed entire corpus on model change | | Dimension | Storage and index memory scale linearly | | Language/domain | General models may miss niche vocabulary | | Cost | API calls vs self-hosted GPU |

On interviews: explain embeddings as learned semantic coordinates—not magic; describe when keyword search still wins (SKUs, exact codes); mention normalization and distance metric choice.

Common pitfalls: tiny chunks with no context; stale embeddings after content edits; mixing models in one index; ignoring metadata filters for multi-tenant data; assuming embeddings replace evaluation.

The trade-off is semantic recall for paraphrases and concepts versus model cost, reindex burden, opacity of relevance, and the need for hybrid keyword + vector retrieval in production.

Checklist:

  • Define embedding as fixed-size semantic vector.
  • Name chunking, model choice, and re-embed triggers.
  • Contrast with inverted-index keyword search.
  • State distance metric and normalization.
  • Tie vectors to metadata and access control.