Client Reference
semantic_router.linear
similarity_matrix
Compute the similarity scores between a query vector and a set of vectors.
Arguments:
xq
: A query vector (1d ndarray)index
: A set of vectors.
Returns:
np.ndarray
: The similarity between the query vector and the set of vectors.
top_scores
Get the top scores and indices from a similarity matrix.
Arguments:
sim
: A similarity matrix.top_k
: The number of top scores to get.
Returns:
Tuple[np.ndarray, np.ndarray]
: The top scores and indices.