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[List[Namespace]] = None) → List[Tuple[Document, float]][source]¶
Return docs most similar to query and their cosine distance from the query.
Parameters
query – String query look up documents similar to.
k – Number of Documents to return. Defaults to 4.
filter – Optional. A list of Namespaces for filtering
the matching results.
For example:
[Namespace(“color”, [“red”], []), Namespace(“shape”, [], [“squared”])]
will match datapoints that satisfy “red color” but not include
datapoints with “squared shape”. Please refer to
https://cloud.google.com/vertex-ai/docs/matching-engine/filtering#json
for more detail.
Returns
List of documents most similar to
the query text and cosine distance in float for each.
Lower score represents more similarity.
Return type
List[Tuple[Document, float]]
Examples using MatchingEngine¶
Google Vertex AI MatchingEngine