k – Number of Documents to return. Defaults to 4.
filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None.
fetch_k – (Optional[int]) Number of Documents to fetch before filtering.
Defaults to 20.
Returns
List of documents most similar to the query text with
Distance as float. Lower score represents more similarity.
similarity_search_with_score_by_vector(embedding: List[float], *, k: int = 4, filter: Optional[Dict[str, Any]] = None, fetch_k: int = 20, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Return docs most similar to query.
Parameters
embedding – Embedding vector to look up documents similar to.
k – Number of Documents to return. Defaults to 4.
filter (Optional[Dict[str, Any]]) – Filter by metadata. Defaults to None.
fetch_k – (Optional[int]) Number of Documents to fetch before filtering.
Defaults to 20.
**kwargs – kwargs to be passed to similarity search. Can include:
nprobe: Optional, number of partitions to check if using IVF_FLAT index
score_threshold: Optional, a floating point value to filter the
resulting set of retrieved docs
Returns
List of documents most similar to the query text and distance
in float for each. Lower score represents more similarity.