MediaPipeTasksRetrieval Framework Reference

UniversalEmbedder

class UniversalEmbedder : NSObject

Performs multi-modal embedding extraction on text, images, audio, or composite content blocks using the native LiteRT-LM EmbeddingEngine.

  • Creates a UniversalEmbedder from a local model file path.

    Declaration

    Swift

    convenience init(modelPath: String) throws
  • Creates a UniversalEmbedder from the given UniversalEmbedderOptions.

    Declaration

    Swift

    init(options: UniversalEmbedderOptions) throws
  • Extracts an embedding from the input text.

    Declaration

    Swift

    func embed(text: String) throws -> EmbeddingResult
  • Extracts an embedding from compressed image data (JPEG/PNG).

    Declaration

    Swift

    func embed(imageBytes: Data) throws -> EmbeddingResult
  • Extracts a multi-modal embedding from an array of TaskPart or media objects.

    Declaration

    Swift

    func embed(content: [Any]) throws -> EmbeddingResult
  • Computes cosine similarity between two Embedding objects.

    Declaration

    Swift

    class func cosineSimilarity(embedding1: Embedding, embedding2: Embedding) throws -> NSNumber