# Unified Multimodal Embeddings: A Practical Guide to Semantic Search on Devices
This guide explains how to build a unified multimodal vector space for semantic search across text, code, images, audio, and video. It covers why identical embedding dimensions do not guarantee a shared semantic space, how to define retrieval units for each modality, the end-to-end search pipeline from ingestion to ranking, on-device resource considerations, vector truncation trade-offs, RAG integration, and evaluation practices. Readers will learn how to design a multimodal retrieval system that is accurate, maintainable, and deployable on local hardware.
1. From Keyword Search to Unified Semantic Retrieval
Enterprise knowledge and personal work materials do not live only in documents. A single technical discussion may leave behind design specs, source code, UI screenshots, meeting recordings, and demo videos. Traditional search typically handles each file type separately: documents rely on text indexes, images on tags, recordings on transcripts, and videos on titles or manual annotations.
This approach solves part of the problem but easily misses cross-media connections. For example, a user searching “the error screen shown after a failed login” may actually need a screenshot; searching “the implementation logic for batch config updates” may target a piece of code that does not use the same wording; searching “the segment where migration risks were discussed” may require finding content hidden inside a meeting recording.
The goal of unified multimodal embeddings is to map different content types into vector representations that can be compared directly, so that search is no longer constrained by file format. Users can retrieve images, audio, or video with natural language queries, or find semantically related materials starting from an existing item.
However, a unified vector space does not eliminate all modality differences. Real systems still need to handle data chunking, permissions, time localization, quality calibration, and result explanation. The model provides the semantic representation; the complete retrieval capability depends on the entire engineering pipeline working together.
2. Same Vector Dimensions Do Not Mean the Same Semantic Space
An embedding is a numerical semantic representation of content. For a piece of text or an image, an encoder outputs a fixed-length vector, and the retrieval system measures its closeness to a query using cosine similarity, inner product, or similar methods.
One important distinction: two encoders that both output vectors of the same dimension do not necessarily produce directly comparable results.
For example, a text encoder and an image encoder may both output 768-dimensional vectors, but without cross-modal alignment training, what each dimension expresses and the overall distribution can still differ. Putting them into the same index will not automatically produce effective image-text retrieval.
A true unified space typically requires training objectives that establish cross-modal associations, so that content with the same or similar meaning ends up close together while unrelated content stays apart. Contrastive learning is one common approach, but specific models may combine different training methods, and output dimensions alone cannot determine capability.
When selecting a model, confirm at least three things:
- Whether it explicitly supports direct retrieval between the target modalities, not just separate encoding;
- Whether the query side and the document side require different input formats or encoding methods;
- Whether the similarity metric the model provides suits your business, and whether additional calibration is needed.
For code retrieval in particular, semantic similarity does not mean implementation correctness. Vector models can help locate candidate functions, but they cannot replace type checking, test verification, or security review.
3. The Key to Unified Retrieval: Defining the Right “Retrieval Unit”
Encoding an entire file into a single vector is simple to implement but often unsuitable for complex materials. The longer and more multi-topic a file is, the more a single vector dilutes local information. A more robust approach is to define retrieval units based on each modality’s structure.
1. Text: Chunk Along Semantic Boundaries
Technical documents should be split by chapters, paragraphs, and list structures rather than cut at a fixed character count. Each chunk should retain the heading path, document source, and necessary adjacent context.
Chunks that are too small may lack explanatory context; chunks that are too large may mix multiple topics. In practice, evaluate granularity with real queries instead of treating any fixed length as universally optimal.
2. Code: Preserve Implementation Structure and Call Context
Code can be indexed by function, class, or logical module, while recording the file path, symbol location, comments, and dependency information.
For a query like “where is retry handled,” function-level representations make locating results easier. For “which processing steps does a request go through,” a single function vector may not be enough; you also need context along the call chain.
Code retrieval can therefore combine semantic recall, symbol matching, and structural information. Vector search surfaces conceptually similar implementations, while exact matching locates explicit targets such as function names, error codes, or configuration keys.
3. Images: Separate Visual and Textual Information
Screenshots often contain interface layout, icons, color states, and readable text all at once. Extracting text alone can lose layout semantics; relying only on visual representations may fail to distinguish small error messages.
A practical approach is to keep the image representation and, when needed, add OCR results with positional metadata. Both types of information can serve different retrieval paths but should point to the same original image, simplifying deduplication and display.
4. Audio and Video: Time Localization Is Essential
Long recordings and videos should usually be processed in segments, with each segment storing start time, end time, and source identifier. Otherwise, even when the system finds the right file, users still have to locate the relevant part themselves.
Audio representations, speech transcripts, and video frame representations each have different strengths. Transcripts work well for finding specific spoken phrases; visual representations for recognizing scenes and actions; whether audio representations preserve non-verbal sound information depends on model capability and training coverage.
Video retrieval also requires attention to sampling strategy. Sampling too sparsely may miss briefly appearing key frames; sampling too densely increases encoding and indexing costs. Choose based on how frequently content changes, how long target events last, and available device resources.
4. The Full Pipeline from Raw Materials to Search Results
A maintainable multimodal retrieval system can be organized as:
Content ingestion → permission and format checks → chunking and preprocessing → modality encoding → vector and metadata storage → candidate recall → re-ranking → result display or answer generation.
Vectors are not the only data that needs to be stored. Each retrieval unit should also be associated with:
- Source material identifier and version;
- Modality type and content location;
- User or organization access permissions;
- Creation time, update time, and business tags;
- Encoding model version, vector dimensionality, and preprocessing version.
This metadata determines whether the index can be updated incrementally, whether results can be traced back, and whether permissions are enforced correctly.
At query time, the system first encodes the query according to the model’s specification, then performs nearest-neighbor search. For exact conditions such as keywords, code symbols, dates, and identifiers, add text search or structured filtering to prevent semantic similarity from overriding explicit constraints.
A unified space can also produce inconsistent score distributions across modalities. If one content type is very numerous or its vectors are more densely distributed, it may dominate the candidate results. Per-modality candidate quotas, score calibration, and re-ranking can help, but these strategies should be driven by evaluation data—never simply add raw scores from different sources together.
Permission constraints should be built into the recall path and checked again before results are returned. Candidate content used for answer generation must also satisfy permission requirements; do not hand it to the generative model first and then try to strip sensitive information from the final answer.
5. On-Device Deployment: Accounting for Resources Beyond the Model
Running embedding models on mobile devices and personal computers offers potential benefits: reduced network dependence, less need to transmit data off-device, and improved response times in some interaction scenarios. But these benefits are not automatic—they must be measured against actual devices and workloads.
On-device resource consumption includes at least:
- Model weights;
- Intermediate tensors and runtime cache during inference;
- Vector data;
- Nearest-neighbor index structures;
- Metadata and any necessary raw content cache.
A small model footprint does not guarantee a lightweight system overall. Video decoding, image preprocessing, and large-scale vector indexing can also become major bottlenecks.
If the model architecture explicitly supports loading modality encoders on demand, applications that only need text and code retrieval can avoid loading unused vision or audio components. But this is a specific architectural design—do not assume all multimodal models support it, and do not casually remove shared components.
During deployment, distinguish between background index building and foreground queries. Document encoding can run during idle time, while charging, or when resources are plentiful; query encoding must prioritize interactive latency. Incremental indexing, duplicate detection, and cache reuse are often more practical than frequently rebuilding the entire library.
6. Vector Truncation: Saves Storage, but Not Arbitrary
Higher embedding dimensions usually mean larger storage and similarity computation costs. If a model is trained with matryoshka representation learning, it may support retrieval using a shorter prefix of the vector, trading dimensionality for resource savings.
This must be emphasized: truncation is only justified when the model explicitly supports this representation. Keeping just the first few dimensions of an ordinary embedding vector can destroy its semantic structure.
As an example, with 1 million vectors, each 768-dimensional with 2 bytes per element, vector storage alone is approximately:
1,000,000 × 768 × 2 bytes = 1.536 billion bytes.
Using 128-dimensional representations at the same element precision, the vectors alone shrink to about 256 million bytes—one-sixth of the original. This only accounts for capacity from dimensionality reduction; it excludes index structures, metadata, file format overhead, and memory management costs.
Truncated vectors usually also need to be re-normalized according to the model’s requirements. Query and document vectors must use consistent dimensionality and processing; representations of different lengths cannot be compared directly.
Quality loss cannot be summarized with a single fixed percentage. Text, images, audio, and video may differ in sensitivity to low-dimensional representations, and domain differences also affect results. Any retention rate or improvement figure should state the task, dataset, metric, and test conditions.
When resources are constrained, consider two-stage retrieval: use short vectors first to broaden candidate recall, then re-rank with full vectors or other ranking methods. But if the full vectors still reside in memory, memory savings will be limited—you must be clear about where each stage’s data lives and what it costs to access.
7. Integrating with RAG: Retrieved Does Not Mean Answered Correctly
Multimodal embeddings can expand the material range for retrieval-augmented generation, but embedding vectors themselves cannot replace original evidence. Retrieved results must point back to document chunks, code locations, image regions, or audio/video time ranges.
If the downstream generative model only accepts text, relevant content must be converted into usable textual evidence, such as transcribed segments, OCR results, or verified descriptions. This conversion can lose information and introduce errors, so the original sources should be preserved for user inspection.
Even if the generative model can handle the relevant modalities, input size, material permissions, and evidence selection still need control. Recalling more content does not guarantee better answers; duplicate or irrelevant chunks can interfere with reasoning.
A reliable answer pipeline should clearly distinguish three levels: what the retrieval system found, what the original material actually says, and what conclusions the generative model can draw from it. For questions with insufficient evidence, state the insufficiency directly rather than using fluent wording to mask the gap.
8. Evaluate on Tasks, Not Model Specs
Whether a solution is worth shipping cannot be judged by parameter counts, dimensions, or public benchmark scores alone. Enterprises should build an evaluation set covering real tasks, for example:
- Finding the corresponding document from a problem description;
- Locating implementation logic with natural language;
- Finding screenshots from interface descriptions;
- Locating recording segments by discussion topic;
- Retrieving video time ranges from event descriptions.
Evaluate candidate recall rate, ranking quality, query latency, index build time, peak memory, and storage consumption separately. Results should also be broken down by modality, query type, and material length to prevent averages from masking localized regressions.
In particular, include hard negatives: functions with similar names but different behavior, interfaces that look alike but represent different states, meeting segments discussing the same topic but reaching different conclusions. These samples better test whether the system understands actual requirements.
When updating models, also check whether old and new vectors are compatible. Do not assume vectors from different versions can be mixed and compared directly. The safe approach is versioned indexes, offline regression testing, and a rollback-ready switch process, with re-encoding of materials when necessary.
9. Rollout Order: Prove Value First, Then Expand Modalities
The value of a unified multimodal space lies in making content connections span file types—not in showcasing that “all five modalities are supported.”
A more sensible build order is: first pick a high-frequency, measurable retrieval task and establish the data and permission pipeline; then validate chunking strategies, vector dimensionality, and recall approaches; finally, add other modalities and generation capabilities based on real demand.
Only when the system can reliably answer “why was this item retrieved,” “is the user authorized to view it,” “where does the result sit in the original file,” and “did quality change after a model upgrade,” does unified multimodal retrieval transform from a model capability into a trustworthy application capability.
