MediaPipeTasksRetrieval Framework Reference

SemanticRetriever

class SemanticRetriever: NSObject

Performs on-device semantic search, vector storage, and query retrieval on text, image, and audio files.

  • Creates a new instance of MPPSemanticRetriever from the given MPPSemanticRetrieverComponents.

    Declaration

    Swift

    class func create(fromComponents components: SemanticRetrieverComponents) throws -> Self

    Parameters

    components

    The components to configure the semantic retriever.

    error

    An optional error parameter populated when there is an error in initializing.

    Return Value

    A new instance of MPPSemanticRetriever. nil if there is an error.

  • Initializes a new instance of MPPSemanticRetriever from the given MPPSemanticRetrieverComponents.

    Declaration

    Swift

    init(components: SemanticRetrieverComponents) throws

    Parameters

    components

    The components to configure the semantic retriever.

    error

    An optional error parameter populated when there is an error in initializing.

    Return Value

    A new instance of MPPSemanticRetriever. nil if there is an error.

  • Deletes records from the vector store for the given list of IDs.

    Declaration

    Swift

    func delete(withIds ids: [String]) throws
  • Deletes records from the vector store matching the metadata filter.

    Declaration

    Swift

    func delete(withMetadataFilter metadataFilter: [String : String]) throws
  • Deletes all records from the vector store.

    Declaration

    Swift

    func deleteAllRecords() throws
  • Retrieves all unique top-level record identifiers in the vector store.

    Declaration

    Swift

    func getAllRecordIds() throws -> [String]
  • Inserts an audio file into the vector store.

    Declaration

    Swift

    func insertAudio(withId recordId: String, filePath: String) throws
  • Inserts an audio file with associated metadata into the vector store.

    Declaration

    Swift

    func insertAudio(withId recordId: String, filePath: String, metadata: [String : String]) throws
  • Inserts multi-modal parts into the vector store.

    Declaration

    Swift

    func insertContent(withId recordId: String, parts: [TaskPart]) throws
  • Inserts multi-modal parts with associated metadata into the vector store.

    Declaration

    Swift

    func insertContent(withId recordId: String, parts: [TaskPart], metadata: [String : String]) throws
  • Inserts a text document into the vector store.

    Declaration

    Swift

    func insertDocument(withId recordId: String, text: String) throws
  • Inserts a text document with associated metadata into the vector store.

    Declaration

    Swift

    func insertDocument(withId recordId: String, text: String, metadata: [String : String]) throws
  • Inserts an image into the vector store.

    Declaration

    Swift

    func insertImage(withId recordId: String, filePath: String) throws
  • Inserts an image with associated metadata into the vector store.

    Declaration

    Swift

    func insertImage(withId recordId: String, filePath: String, metadata: [String : String]) throws
  • Retrieves the topK nearest records matching the precomputed query embedding.

    Declaration

    Swift

    func retrieve(withEmbedding queryEmbedding: [NSNumber], topK: Int) throws -> [RetrievalResult]
  • Retrieves the topK nearest records matching the precomputed query embedding and metadata filter.

    Declaration

    Swift

    func retrieve(withEmbedding queryEmbedding: [NSNumber], topK: Int, metadataFilter: [String : String]?) throws -> [RetrievalResult]
  • Retrieves the topK nearest records matching the multi-modal query parts.

    Declaration

    Swift

    func retrieve(withParts queryParts: [TaskPart], topK: Int) throws -> [RetrievalResult]
  • Retrieves the topK nearest records matching the multi-modal query parts and metadata filter.

    Declaration

    Swift

    func retrieve(withParts queryParts: [TaskPart], topK: Int, metadataFilter: [String : String]?) throws -> [RetrievalResult]
  • Retrieves the topK nearest records matching the query string.

    Declaration

    Swift

    func retrieve(withText queryText: String, topK: Int) throws -> [RetrievalResult]
  • Retrieves the topK nearest records matching the query string and metadata filter.

    Declaration

    Swift

    func retrieve(withText queryText: String, topK: Int, metadataFilter: [String : String]?) throws -> [RetrievalResult]