Returns
List of Documents selected by maximal marginalrelevance to the query and score for each.
Return type
List[Tuple[Document, float]]
max_marginal_relevance_search_with_score_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Return docs selected using the maximal marginal relevance with scoreto embedding vector.
Maximal marginal relevance optimizes for similarity to query AND diversityamong selected documents.
Parameters
embedding – Embedding to look up documents similar to.
k (int) – Number of Documents to return. Defaults to 4.
fetch_k (int) – Number of Documents to fetch to pass to MMR algorithm.
Defaults to 20.
lambda_mult (float) – 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.
filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None.
Returns
List of Documents selected by maximal marginalrelevance to the query and score for each.
Return type
List[Tuple[Document, float]]
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, filter: Optional[dict] = None, **kwargs: Any) → List[Document][source]¶
Run similarity search with PGVector with distance.
Parameters
query (str) – Query text to search for.