Semantic search utilities matching sentence_transformers.util.semantic_search.
Summary
Functions
Performs semantic search between query embeddings and corpus embeddings.
Functions
Performs semantic search between query embeddings and corpus embeddings.
Returns a list of search results for each query:
[[%{corpus_id: 0, score: 0.95}, ...], ...] sorted in descending order of score.
With Nx.BinaryBackend, equal scores prefer lower corpus IDs. Other backends
follow their Nx.top_k/2 tie-selection behavior; membership at a tied cutoff
may differ.
Options
:top_k- number of top matches to return per query. Defaults to10.:query_chunk_size- number of queries to score at once. Defaults to100.:corpus_chunk_size- number of corpus embeddings to score at once. Defaults to10_000.:score_function- similarity function to use. Can be:cos_sim(default),:dot_score,:euclidean_sim,:manhattan_sim, or a custom functionfun.(query, corpus).