UniversalEmbedder
final class UniversalEmbedder: Sendable, MediaPipeTasksCommon.EmbeddingProviderExtracts multimodal embeddings from text, images, audio, or composite TaskPart sequences.
@unchecked Sendable is safe because embedder is immutable after initialization and all native inference calls are serialized through lock.
-
Computes the cosine similarity between
embedding1andembedding2in[-1.0, 1.0].Declaration
Swift
static func cosineSimilarity(embedding1: Embedding, embedding2: Embedding) throws -> Double -
Creates an embedder from a local
.litertlmmodel file atmodelPathwith default options.Declaration
Swift
convenience init(modelPath: String) throws -
Creates an embedder configured with
options.Declaration
Swift
init(options: UniversalEmbedderOptions) throws -
Computes an embedding for
audio.Declaration
Swift
final func embed(audio: AudioData) throws -> EmbeddingResult -
Computes an embedding for mono PCM samples in
audioFloatBuffer.Declaration
Swift
final func embed(audioFloatBuffer: FloatBuffer) throws -> EmbeddingResult -
Computes a joint embedding across multimodal
contentparts.Declaration
Swift
final func embed(content: [TaskPart]) throws -> EmbeddingResult -
Computes an embedding for an
MPImage.Declaration
Swift
final func embed(image: MPImage) throws -> EmbeddingResult -
Computes an embedding for compressed
imageBytes(such as JPEG, PNG, or TGA).Declaration
Swift
final func embed(imageBytes: Data) throws -> EmbeddingResult -
Computes an embedding for UTF-8
text.Declaration
Swift
final func embed(text: String) throws -> EmbeddingResult