Sting.Search (Sting v0.1.0)

Copy Markdown View Source

Semantic search utilities matching sentence_transformers.util.semantic_search.

Summary

Functions

Performs semantic search between query embeddings and corpus embeddings.

Functions

semantic_search(query_embeddings, corpus_embeddings, opts \\ [])

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 to 10.
  • :query_chunk_size - number of queries to score at once. Defaults to 100.
  • :corpus_chunk_size - number of corpus embeddings to score at once. Defaults to 10_000.
  • :score_function - similarity function to use. Can be :cos_sim (default), :dot_score, :euclidean_sim, :manhattan_sim, or a custom function fun.(query, corpus).