k – Number of Documents to return. Defaults to 4.
fetch_k – Number of Documents to fetch to pass to MMR algorithm.
lambda_mult – Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
Returns
List of Documents selected by maximal marginal relevance.
search(query: str, search_type: str, **kwargs: Any) → List[Document]¶
Return docs most similar to query using specified search type.
similarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document][source]¶
Run similarity search on query
Parameters
query (str) – Query
k (int) – Number of results to return. Defaults to 4.
Returns
List of Documents most similar to the query
similarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document][source]¶
Run similarity search on query embedding
Parameters
embedding (List[float]) – Query embedding
k (int) – Number of results to return. Defaults to 4.
Returns
List of Documents most similar to the query
similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Run similarity search synchronously and return relevance scores
Parameters
query (str) – Query
k (int) – Number of results to return. Defaults to 4.
Returns
List of Documents most similar along with relevance scores
similarity_search_with_score(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Run similarity search synchronously and return distance scores
Parameters