@v0xium: LLM Inference Engineering: Embedding Models Explained 1. An Embedding Model (EM) converts a chunk of text, or any other…
Summary
This article explains embedding models and their role in LLM inference, covering architectures, traffic profiles, and optimization techniques like quantization.
View Cached Full Text
Cached at: 08/24/26, 03:52 PM
LLM Inference Engineering: Embedding Models Explained
-
An Embedding Model (EM) converts a chunk of text, or any other modality, into a fixed-length vector that captures the semantic meaning/context of the input.
-
Once we have the representation vectors, we can compare the distances between them using simple vector math. That is why these models can be used to build agent memory, RAG applications, search, and recommendation systems.
-
There are two types of traffic profiles for EMs:
- High-throughput backfills: Big bulk operations like indexing millions of documents, preparing data for LLM training, etc.
- Low-latency lookups: User queries for search, retrieval, recommendation, etc. We need to be fast because each extra millisecond affects the UX.
-
Inference Engineering for EMs should start by asking a question: Which profile are we serving? For example, if you need to support both and have enough traffic, you can build separate systems for both types of usage.
-
Most EMs use one of these two types of architectures. Both of them are transformer-based:
- BERT-style: Encoder-only NNs.
- LLM-based: Modern language models, but repurposed to generate embeddings.
-
BERT-style models are still used for simple, latency-sensitive tasks like classification. But the bulk of usage is of LLM-based models.
-
They have their own tradeoffs between speed and quality. The size of the output vectors, or embedding dimensionality, can affect this.
-
Dimensionality does not mostly affect inference time, but it affects the storage, retrieval, and distance computation time of the EM system.
-
In most cases, vectors from one EM cannot be compared to a vector from another EM.
-
Inference gains can also come from quantization. FP8 for a larger embedding model offers improved performance with minimal quality loss.
-
To check the quality of an EM post-quantization, you can run the input through the original and quantized versions and check the cosine similarity of the two output vectors. A 99% similarity will indicate good quantization.
(end)
This is the collection of notes made while reading Inference Engineering Book by Philip Kiely. More posts will be there soon.
Image Source: Choosing an Embedding Model, Pinecone.
Similar Articles
The Embedder's Dilemma: LLMs Are Better, but at What Cost?
This paper presents a cost-aware comparison of LLMs versus dedicated embedding models across 37 tasks, finding that the best LLM and embedding model are nearly tied on aggregate performance but LLMs are up to 1,431x more expensive and slower, leading to a recommended division of labor.
The Embedder's Dilemma: LLMs Are Better, but at What Cost?
The paper compares large language models and embedding models across 37 tasks, finding that while aggregate performance is similar, embedding models are far cheaper and faster, supporting a division of labor for cost-efficiency.
@CamilleRoux: Une explication bien faite du fonctionnement interne des LLMs : tokens, embeddings, positional encoding, attention, fee…
This tweet shares a well-made explanation of the internal workings of LLMs, covering tokens, embeddings, positional encoding, attention, and feed-forward networks, via a blog post by 0xkato.
LLM-Based Embeddings for Program Analysis and Optimization
This paper presents the first application of program embeddings from LLMCompiler, an LLM pretrained on IR code, to program analysis and optimization tasks, achieving a 1.54% error rate in algorithm classification and competitive accuracy on heterogeneous device mapping.
How LLMs Actually Work (26 minute read)
A detailed walkthrough of how transformer-based LLMs work, covering tokenization, embeddings, attention, and next-token prediction without heavy math.