An embedding is a dense vector of numbers representing the meaning of text. Passages with similar meanings can have nearby vectors even when they use different words. This makes embeddings useful for finding relevant organizational knowledge that keyword matching might miss. section 5.1 section 5.0
Matching a return-policy question
A question about returning an opened laptop can match a passage about electronics returns and restocking fees, despite their different wording. The result is a passage that can ground an answer, rather than a match based only on shared keywords. section 5.1
In a retrieval pipeline, documents are parsed and split into semantically coherent chunks. An embedding model converts each chunk into a vector; a vector store keeps those vectors alongside the chunk text and metadata. At search time, the question is embedded and compared with stored vectors. Results include source attribution and relevance scores so a workflow can use them as context. section 5.1 section 5.3
Figure 5.1 The retrieval pipeline from document to search result. A source document enters the ingestion pipeline, where it is parsed into clean text and then broken into semantically coherent chunks. Each chunk is passed through an embedding model to produce a dense vector representation. The vectors, along with the original chunk text and metadata, are stored in a vector database. At query time, the user's question follows the same embedding process to produce a query vector, which is compared against stored vectors using similarity search. The top matching chunks are returned with their source attribution, relevance scores, and metadata, ready to be injected into the model's context as grounding information.

Follow the document and query paths from chunking and embedding to similarity search and grounded results. section 5.1
Generate embeddings through the Model Service rather than calling providers directly from the Data Service. Embedding takes text and returns vectors, while sharing provider abstraction, cost tracking, routing, and retry logic with other model operations. During ingestion, batching chunks reduces the number of API calls. section 5.3.6 section 3.1.5
Listing 5.12 Embedding generation through the Model Service
class EmbeddingGenerator:
def __init__(self, model_client): #A
self.model_client = model_client
def embed_chunks(
self,
chunks: List[Chunk],
model: str = "text-embedding-3-small",
batch_size: int = 100 #B
) -> List[List[float]]:
all_embeddings = []
for i in range(0, len(chunks), batch_size):
batch = chunks[i:i + batch_size]
texts = [chunk.text for chunk in batch]
response = self.model_client.embed( #C
texts=texts,
model=model
)
all_embeddings.extend(response.embeddings)
return all_embeddings
def embed_query(
self, query: str, model: str
) -> List[float]: #D
response = self.model_client.embed(
texts=[query],
model=model
)
return response.embeddings[0]Inspect the generator interface for batching chunk texts and requesting embeddings through the Model Service. section 5.3.6
Keep these decisions explicit when operating semantic search:
- Use the index's embedding model for both its chunks and each query. Search orchestration reads that model from the index configuration before embedding the query. section 5.4.4
- Choose vector dimensions with storage and latency in mind. Some models allow configurable dimensions, trading retrieval quality against efficiency. section 5.3.6
- Plan for scale: exhaustive comparison becomes impractical across millions of vectors, so production vector stores use approximate nearest-neighbor algorithms to narrow candidates. section 5.1
- Use hybrid search when exact keywords or identifiers matter. Vector similarity works well for natural-language semantic queries but can struggle with exact matches. section 5.4.4







































































