similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶
Return docs and relevance scores in the range [0, 1].
0 is dissimilar, 1 is most similar.
Parameters
query – input text
k – Number of Documents to return. Defaults to 4.
**kwargs – kwargs to be passed to similarity search. Should include:
score_threshold: Optional, a floating point value between 0 to 1 to
filter the resulting set of retrieved docs
Returns
List of Tuples of (doc, similarity_score)
similarity_search_with_score(query: str, k: int = 4, filter: Optional[RedisFilterExpression] = None, return_metadata: bool = True, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Run similarity search with vector distance.
The “scores” returned from this function are the raw vector
distances from the query vector. For similarity scores, use
similarity_search_with_relevance_scores.
Parameters
query (str) – The query text for which to find similar documents.
k (int) – The number of documents to return. Default is 4.
filter (RedisFilterExpression, optional) – Optional metadata filter.
Defaults to None.
return_metadata (bool, optional) – Whether to return metadata.
Defaults to True.
Returns
A list of documents that aremost similar to the query with the distance for each document.
Return type
List[Tuple[Document, float]]
write_schema(path: Union[str, PathLike]) → None[source]¶
Write the schema to a yaml file.
Examples using Redis¶
Redis