TextEmbedder
final class TextEmbedderExtracts numerical feature embeddings from UTF-8 text using a MediaPipe Tasks model.
-
Computes the cosine similarity between two embeddings in
[-1.0, 1.0].Declaration
Swift
static func cosineSimilarity(embedding1: Embedding, embedding2: Embedding) throws -> Double -
Initializes a
TextEmbedderfrom a local model file path with default options.Declaration
Swift
convenience init(modelPath: String) throws -
Initializes the MediaPipe text embedder task graph from
options.Declaration
Swift
init(options: TextEmbedderOptions) throws -
Extracts feature embeddings for
textusing optional prompt-formatting instructions.Declaration
Swift
final func embed(text: String, textFormatContext: TextFormatContext? = nil) throws -> TextEmbedderResult