AI ENGINEERING — ACTIVE CONCEPTS & PRACTICES | #003
Embeddings in Practice: Making Information Searchable by Meaning
Chapter 1: Engineering the AI Context
AIYING — Accomplishing with AI
The Big Idea: Traditional keyword search identifies matching words. Embeddings enable AI systems to identify relationships between information based on learned semantic representations.
For AI engineers, embeddings are not merely mathematical vectors. They are practical building blocks for semantic search, retrieval-augmented generation, recommendations, and knowledge discovery.
Contents
- Why Embeddings Matter
- UNDERSTAND — What Are Embeddings?
- CONNECT — The AI Engineering Ecosystem
- How Semantic Retrieval Works
- APPLY — An Enterprise Engineering Scenario
- Engineering Decisions and Trade-offs
- Active Industry Practices
- ACCOMPLISH — Practical Exercise
- Student and Practitioner Project
- Check Your Understanding
- Active Connections
- References and Further Reading
1. Why Embeddings Matter
Imagine an employee searching an organization's knowledge base for:
"How can I reduce the electricity used by our production equipment?"
The most useful document may be titled:
"Industrial Energy Efficiency and Equipment Optimization Guidelines."
The query and document do not use exactly the same words. Yet they address closely related ideas.
A keyword-based system may miss the document if it relies heavily on exact term matching.
An embedding-based retrieval system can represent the query and document in a numerical space where semantically related content may appear close together.
This makes embeddings valuable for applications where users and documents express similar meanings in different language.
However, semantic similarity is not the same as factual correctness, relevance to a specific user, or permission to access a document.
Embeddings help machines compare meaning. Engineering determines whether those comparisons produce useful results.
↑ Back to Contents
2. UNDERSTAND — What Are Embeddings?
The basic concept
An embedding is a numerical vector representing an item such as a piece of text, an image, or another supported type of data.
An embedding model learns to position related items in a mathematical representation space.
For example, an embedding for "automobile" may be closer to an embedding for "car" than to one for "banana", depending on the model and context.
These relationships are learned, not manually programmed for every word.
What is a vector?
A vector is an ordered collection of numerical values.
Example vector: [0.12, -0.38, 0.74, 0.09]
This four-dimensional vector is illustrative. Production embedding models commonly generate vectors with hundreds or thousands of dimensions.
Individual dimensions generally do not correspond to simple, independently interpretable concepts.
From text to vector
Text or Document
↓
Embedding Model
↓
Numerical Vector
↓
Similarity Comparison
↓
Potentially Relevant Results
What is semantic similarity?
Semantic similarity concerns how closely two items relate in meaning.
One common mathematical measure is cosine similarity.
Cosine Similarity = (A · B) / (||A|| × ||B||)
The formula compares the angle between two nonzero vectors. A higher cosine similarity often indicates a closer relationship in the embedding space.
For normalized vectors, cosine similarity and dot-product ranking are closely related.
Different embedding models, distance metrics, and data distributions can produce different rankings.
What embeddings do not guarantee
- They do not prove that retrieved information is factually correct.
- They do not automatically understand organizational access permissions.
- They may struggle with exact identifiers, rare terminology, or numerical distinctions.
- They do not replace evaluation of retrieval relevance.
↑ Back to Contents
3. CONNECT — The AI Engineering Ecosystem
Embeddings connect several important AI engineering components.
| Connected Concept | Engineering Relationship |
| Tokenization | Text is tokenized as part of processing by text embedding models. |
| Context Engineering | Embeddings help identify information worth including in model context. |
| Vector Databases | Store or index embeddings for similarity search. |
| RAG | Uses retrieval to supply external knowledge to a generative model. |
| Chunking | Determines the units of content represented by embeddings. |
| Reranking | Can improve the ordering of initially retrieved candidates. |
| Hybrid Search | Combines semantic retrieval with lexical or keyword search. |
| Recommendations | Helps identify items with similar learned characteristics. |
| Multimodal AI | Some models map text, images, or other modalities into compatible representation spaces. |
| Evaluation | Measures whether retrieval returns the right information. |
Embeddings and generative AI
Embedding models and generative language models perform different tasks.
An embedding model converts information into a representation suitable for comparison or retrieval.
A generative language model produces responses, summaries, code, or other outputs.
In a RAG application, embeddings may help retrieve information that is subsequently supplied to a generative model.
They are complementary capabilities, not interchangeable ones.
↑ Back to Contents
4. How Semantic Retrieval Works
A typical embedding-based retrieval system has two workflows.
A. Document indexing
- Collect approved documents.
- Extract and clean their content.
- Divide long documents into useful chunks.
- Generate an embedding for each chunk.
- Store embeddings alongside document identifiers and metadata.
- Create or update a similarity-search index.
B. Query retrieval
- Receive the user's question.
- Generate a query embedding using a compatible embedding configuration.
- Apply relevant access and metadata constraints.
- Search for similar document embeddings.
- Retrieve candidate passages.
- Optionally rerank the candidates.
- Supply selected passages to the generative model, if the application uses RAG.
Documents → Chunks → Embeddings → Vector Index
User Query → Query Embedding → Similarity Search
↓
Relevant Passages → AI Response
In practice, filtering, retrieval, and reranking order can vary by database and application architecture.
Large-scale systems often use approximate nearest-neighbor algorithms to accelerate similarity search, trading some retrieval precision for speed and resource efficiency.
↑ Back to Contents
5. APPLY — An Enterprise Engineering Scenario
Scenario: A Food Manufacturing Knowledge Assistant
A food manufacturing company maintains thousands of technical documents covering quality control, food safety, packaging, equipment maintenance, and sustainability.
Engineers and quality professionals need to find relevant information quickly.
An employee asks:
"How can we reduce packaging waste without affecting product shelf life?"
Relevant documents may contain phrases such as:
- Packaging material optimization
- Barrier properties and shelf-life performance
- Material reduction strategies
- Life-cycle assessment of packaging
Approach A: Keyword-only search
A lexical search engine retrieves documents based on term matches and its ranking rules.
It can be effective for exact terminology, product identifiers, and known phrases, but may miss semantically related passages with different wording.
Approach B: Embedding-based semantic search
The application represents documents and queries using embeddings and retrieves semantically similar passages.
This may surface useful documents even when their terminology differs from the user's question.
Approach C: Hybrid retrieval
The engineering team combines lexical search and embedding-based retrieval.
This can support both exact technical terminology and meaning-based discovery.
For example, the system may need to recognize both a precise packaging specification and broader concepts such as material efficiency.
Engineering insight
The most appropriate search strategy depends on the organization's information, user questions, terminology, and retrieval requirements.
Embedding-based search should not be assumed superior without evaluation.
↑ Back to Contents
6. Engineering Decisions and Trade-offs
| Decision | Trade-off |
| Embedding model | Retrieval quality, language coverage, dimensionality, cost, and latency |
| Chunk size | Fine-grained relevance versus loss of surrounding context |
| Vector dimensions | Storage and search efficiency versus representation quality |
| Similarity metric | Cosine similarity, dot product, or distance-based retrieval |
| Search method | Exact nearest neighbors versus approximate indexing |
| Top-k results | Retrieval coverage versus irrelevant context and token cost |
| Hybrid retrieval | Improved lexical and semantic coverage versus architectural complexity |
| Reranking | Potentially better relevance versus additional cost and latency |
| Embedding updates | Improved models versus reindexing and compatibility requirements |
A frequently overlooked issue: embedding compatibility
Document embeddings and query embeddings must be generated using compatible configurations.
Replacing an embedding model may require regenerating stored vectors and rebuilding the index.
Even if two models produce vectors of the same length, their representation spaces are not necessarily compatible.
Security and privacy
Embeddings can encode information derived from sensitive documents. Vector databases and retrieval systems require appropriate security controls.
Access control must apply to the underlying documents and retrieved results, not merely to the user interface.
↑ Back to Contents
7. Active Industry Practices
Established applications
- Enterprise document search
- Retrieval-augmented generation
- Knowledge-base assistants
- Product and content recommendations
- Document clustering and classification
- Duplicate and near-duplicate detection
Evolving engineering practices
- Hybrid retrieval combining dense and lexical methods
- Task-specific embedding model selection
- Multilingual semantic retrieval
- Multimodal retrieval across text and images
- Retrieval evaluation using representative query sets
- Embedding model migration and index version management
What is still an engineering challenge?
Embeddings can represent broad semantic relationships but may not reliably capture every domain-specific distinction.
In specialized fields such as medicine, law, engineering, and food safety, a small difference in terminology can have major consequences.
Engineers must test retrieval performance using actual domain questions and documents.
Practice status: Established capability with evolving models, indexing methods, and retrieval architectures.
Reviewed: November 2026.
↑ Back to Contents
8. ACCOMPLISH — Practical Exercise
Exercise: Discover Meaning-Based Search
Prepare five short document descriptions:
- Reducing electricity consumption in manufacturing equipment.
- Improving energy efficiency in industrial production.
- Managing employee annual leave.
- Reducing packaging material waste.
- Improving product shelf-life stability.
Now create the query:
How can a factory lower its power usage?
Your task
Use an embedding-capable application or a simple embedding API to:
- Generate embeddings for all five descriptions.
- Generate an embedding for the query.
- Calculate similarity scores between the query and descriptions.
- Rank the descriptions by similarity.
- Compare the results with a simple keyword-matching approach.
- Explain why semantically related passages may be retrieved despite different wording.
Example Python workflow
The following illustrative example uses the OpenAI Python SDK. It requires the SDK, NumPy, and an API key with access to the selected embedding model.
import os
import numpy as np
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
documents = [
"Reducing electricity consumption in manufacturing equipment",
"Improving energy efficiency in industrial production",
"Managing employee annual leave",
"Reducing packaging material waste",
"Improving product shelf-life stability"
]
query = "How can a factory lower its power usage?"
texts = documents + [query]
response = client.embeddings.create(
model="text-embedding-3-small",
input=texts
)
vectors = [
np.array(item.embedding)
for item in response.data
]
query_vector = vectors[-1]
def cosine_similarity(a, b):
return np.dot(a, b) / (
np.linalg.norm(a) * np.linalg.norm(b)
)
results = [
(document, cosine_similarity(vector, query_vector))
for document, vector in zip(documents, vectors[:-1])
]
for document, score in sorted(
results,
key=lambda x: x[1],
reverse=True
):
print(f"{score:.3f} | {document}")
Scores and rankings depend on the selected embedding model. The exercise does not prescribe an expected numerical result.
Accomplishment: You have built a basic semantic similarity search experiment and observed how embeddings support meaning-based retrieval.
↑ Back to Contents
9. Student and Practitioner Project
Mini Project: Enterprise Semantic Knowledge Finder
Objective: Design a searchable knowledge base using embeddings.
Suggested project steps
- Collect 20–50 short, non-sensitive documents from a selected domain.
- Prepare 10 realistic search questions.
- Create a keyword-based retrieval baseline.
- Generate document embeddings.
- Build a semantic search workflow.
- Compare retrieval results for the same questions.
- Test a hybrid retrieval approach if tools are available.
- Document strengths, weaknesses, and engineering trade-offs.
Suggested evaluation metrics
- Recall@k: Proportion of relevant documents retrieved in the top k results.
- Precision@k: Proportion of the top k retrieved results that are relevant.
- MRR: Mean Reciprocal Rank of the first relevant result.
- Retrieval latency: Time taken to return results.
- Index size: Storage consumed by the representations and index.
Prepare relevance judgments for your test questions before calculating these metrics.
Deliverable: A working prototype or design demonstration, evaluation table, and short recommendation explaining when semantic search is appropriate.
↑ Back to Contents
10. Check Your Understanding
- What does an embedding represent?
- How does semantic search differ from keyword search?
- Why are embedding models and generative language models different?
- How are embeddings used in RAG?
- What are the trade-offs in selecting chunk size and vector dimensions?
- Why should embeddings not be treated as proof of factual correctness?
- When might hybrid retrieval outperform purely semantic search?
Reflection: In your organization or field of study, what information is difficult to discover because people use different terminology to describe the same idea?
↑ Back to Contents
11. Active Connections
This lesson connects directly with:
These connections show how embeddings form part of a larger information retrieval and context engineering system.
↑ Back to Contents
12. References and Further Reading
- OpenAI — Embeddings Guide
- Pinecone — Vector Embeddings
- Sentence Transformers — Documentation
- FAISS — Similarity Search and Clustering
- Elastic — Semantic Search
Model specifications, API capabilities, and retrieval practices evolve. Consult current technical documentation before implementing production systems.
Final Takeaway
Embeddings make meaning computationally searchable. Effective AI engineering turns that capability into reliable, secure, measurable, and useful information retrieval.
AI Engineering — Active Concepts & Practices
Active Concept #003 — Embeddings in Practice
AIYING — Accomplishing with AI
Understand → Connect → Apply → Accomplish