mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 15:03:21 +00:00
Implemented MMR search for Redis (#10140)
Description: Implemented MMR search for Redis. Pretty straightforward, just using the already implemented MMR method on similarity search–fetched docs. Issue: #10059 Dependencies: None Twitter handle: @hamza_tahboub --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
@@ -413,7 +413,8 @@
|
||||
"- ``similarity_search``: Find the most similar vectors to a given vector.\n",
|
||||
"- ``similarity_search_with_score``: Find the most similar vectors to a given vector and return the vector distance\n",
|
||||
"- ``similarity_search_limit_score``: Find the most similar vectors to a given vector and limit the number of results to the ``score_threshold``\n",
|
||||
"- ``similarity_search_with_relevance_scores``: Find the most similar vectors to a given vector and return the vector similarities"
|
||||
"- ``similarity_search_with_relevance_scores``: Find the most similar vectors to a given vector and return the vector similarities\n",
|
||||
"- ``max_marginal_relevance_search``: Find the most similar vectors to a given vector while also optimizing for diversity"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -596,6 +597,26 @@
|
||||
"print(results[0].metadata)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# use maximal marginal relevance search to diversify results\n",
|
||||
"results = rds.max_marginal_relevance_search(\"foo\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# the lambda_mult parameter controls the diversity of the results, the lower the more diverse\n",
|
||||
"results = rds.max_marginal_relevance_search(\"foo\", lambda_mult=0.1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
Reference in New Issue
Block a user