Back to Generative AI Notes
Topic #89

Embedding Models

An embedding model is a separate, specialized model from a general-purpose LLM — trained specifically to produce vectors where distance reflects semantic similarity, not to generate fluent text.

Embedding Models vs LLMs — Different Jobs

LLM (e.g. a chat model)Embedding Model
InputA promptA piece of text
OutputGenerated text, token by tokenOne fixed-size vector, in a single pass
Training objectivePredict the next token accuratelyProduce vectors where similar-meaning texts are close together
Typical costHigher, scales with output lengthLower, fixed per input

Some providers offer embedding models as a completely separate product/API from their chat/generation models — worth checking whether your provider's embedding model is a distinct, purpose-built model rather than assuming it's "the same model" used for chat.

Embedding Models Differ From Each Other Too

  • Dimensionality — different models output vectors of different sizes (see Embedding Dimensions)
  • Training domain — some are general-purpose; others are tuned for specific domains (code, multilingual text, specific industries)
  • Max input length — embedding models have their own input length limits, separate from any LLM's context window

Important: Vectors From Different Models Aren't Interchangeable

# WRONG — comparing vectors from two different embedding models
vector_a = model_A.embed("some text")
vector_b = model_B.embed("other text")
similarity = cosine_similarity(vector_a, vector_b)  # meaningless —
                                                       # different
                                                       # models produce
                                                       # incompatible
                                                       # vector spaces

All vectors compared to each other in a search/retrieval system must come from the same embedding model — mixing models (or switching models without re-embedding existing content) silently breaks similarity comparisons.

Practical Use Case

Choosing an embedding model is a real decision — general-purpose models work well for most applications, but a domain-specific model (e.g. one trained on code, or on a specific language) can meaningfully outperform a general model for that specific use case.

Common Mistakes

  • Switching embedding models without re-embedding all previously stored content — old and new vectors become incompatible, silently corrupting search quality
  • Assuming a general-purpose embedding model is automatically the best choice for a specialized domain (like source code) without testing

Interview Relevance

"If you switch your embedding model, what has to happen to your existing vector database?" — every previously stored vector must be regenerated with the new model; old and new vectors aren't comparable, a commonly overlooked migration cost.

Practice Question

Explain why a support-search system that switched embedding models but forgot to re-embed its existing 50,000 stored documents would start returning poor search results.

Want to go beyond the notes?

Join Coding Now Tech Institute's Generative AI course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Embedding Models – FAQs

Quick answers about learning Embedding Models in Generative AI.

This free note from Coding Now Tech Institute explains Embedding Models in Generative AI — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Generative AI topic on Coding Now Tech Institute, including Embedding Models, is 100% free with no signup required.
With focused practice, most students grasp Embedding Models in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now