From 2e929bddad35a574330a157ae8e2788371b9f6d1 Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Mon, 18 Dec 2023 11:12:40 -0800 Subject: [PATCH] Remove embeddings from results + cleanup comments --- .../vectorstores/mongodb_atlas.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/mongodb_atlas.py b/libs/community/langchain_community/vectorstores/mongodb_atlas.py index d0a7f486c08a8..6a242d8731435 100644 --- a/libs/community/langchain_community/vectorstores/mongodb_atlas.py +++ b/libs/community/langchain_community/vectorstores/mongodb_atlas.py @@ -192,6 +192,7 @@ def _similarity_search_with_score( for res in cursor: text = res.pop(self._text_key) score = res.pop("score") + del res["embedding"] docs.append((Document(page_content=text, metadata=res), score)) return docs @@ -205,12 +206,8 @@ def similarity_search_with_score( ) -> List[Tuple[Document, float]]: """Return MongoDB documents most similar to the given query and their scores. - Uses the knnBeta Operator available in MongoDB Atlas Search. - This feature is in early access and available only for evaluation purposes, to - validate functionality, and to gather feedback from a small closed group of - early access users. It is not recommended for production deployments as we - may introduce breaking changes. - For more: https://www.mongodb.com/docs/atlas/atlas-search/knn-beta + Uses the vectorSearch operator available in MongoDB Atlas Search. + For more: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/ Args: query: Text to look up documents similar to. @@ -218,7 +215,7 @@ def similarity_search_with_score( pre_filter: (Optional) dictionary of argument(s) to prefilter document fields on. post_filter_pipeline: (Optional) Pipeline of MongoDB aggregation stages - following the knnBeta vector search. + following the vectorSearch stage. Returns: List of documents most similar to the query and their scores. @@ -242,12 +239,8 @@ def similarity_search( ) -> List[Document]: """Return MongoDB documents most similar to the given query. - Uses the knnBeta Operator available in MongoDB Atlas Search. - This feature is in early access and available only for evaluation purposes, to - validate functionality, and to gather feedback from a small closed group of - early access users. It is not recommended for production deployments as we - may introduce breaking changes. - For more: https://www.mongodb.com/docs/atlas/atlas-search/knn-beta + Uses the vectorSearch operator available in MongoDB Atlas Search. + For more: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/ Args: query: Text to look up documents similar to. @@ -255,7 +248,7 @@ def similarity_search( pre_filter: (Optional) dictionary of argument(s) to prefilter document fields on. post_filter_pipeline: (Optional) Pipeline of MongoDB aggregation stages - following the knnBeta vector search. + following the vectorSearch stage. Returns: List of documents most similar to the query and their scores. @@ -300,7 +293,7 @@ def max_marginal_relevance_search( pre_filter: (Optional) dictionary of argument(s) to prefilter on document fields. post_filter_pipeline: (Optional) pipeline of MongoDB aggregation stages - following the knnBeta vector search. + following the vectorSearch stage. Returns: List of documents selected by maximal marginal relevance. """