In a significant advancement for AI applications, the Sentence Transformers library has unveiled its v5.4 update, which introduces the ability to encode and compare multiple modalities—text, images, audio, and video—using a cohesive API.
Understanding Multimodal Models
Traditionally, embedding models have focused on converting text into fixed-size vectors. The new multimodal embedding models extend this capability by mapping inputs from various modalities into a shared embedding space. This allows users to compare text queries with image documents and vice versa, utilizing familiar similarity functions.
Moreover, multimodal reranker models enhance the process by scoring the relevance of mixed-modality pairs, facilitating applications such as visual document retrieval and cross-modal searches.
Installation and Model Loading
To leverage these multimodal features, users need to install additional dependencies tailored to their specific requirements. For instance, to enable image support, one would execute:
pip install -U "sentence-transformers[image]"
Models like Qwen3-VL-Embedding-2B can be loaded seamlessly, with the model automatically detecting supported modalities. The loading process mirrors that of text-only models, ensuring a smooth transition for users familiar with the library.
Encoding and Similarity Computation
With a multimodal model in place, users can encode images alongside text. The model supports various input formats, including URLs and local file paths. For example, encoding images from URLs yields embeddings that can be compared against text embeddings:
similarities = model.similarity(text_embeddings, img_embeddings)
This functionality allows for the computation of cross-modal similarities, although it is noted that scores may not reach the maximum due to the inherent modality gap.
Reranking and Document Retrieval
The multimodal reranker models provide a more nuanced scoring of relevance between pairs of inputs, which can include any combination of text, images, audio, or video. The rank() method allows for the scoring and ranking of documents against a query, effectively identifying the most relevant results.
For instance, when querying about a green car, the model accurately ranks the corresponding image as the top result, showcasing its capability to handle mixed modalities effectively.
In summary, the v5.4 update to Sentence Transformers marks a notable enhancement in multimodal processing, providing robust tools for developers and researchers to explore the intersections of various data types.
This article was produced by NeonPulse.today using human and AI-assisted editorial processes, based on publicly available information. Content may be edited for clarity and style.
Original source: huggingface.co








