Learn R Programming

textpress (version 1.1.0)

search_vector: Vector search by cosine similarity

Description

Returns the top-n matches from an embedding matrix for one or more query vectors. Subject-first: embeddings (haystack) then query (needle), pipe-friendly.

Usage

search_vector(embeddings, query, n = 10)

Value

A data frame (or list of data frames if multiple queries are provided) containing the match identifiers and similarity scores.

Arguments

embeddings

A numeric or sparse matrix of embeddings (rows = searchable units).

query

A character (row name in embeddings), a numeric vector (single query), or a numeric matrix (multiple queries).

n

Number of results to return per query (default 10).