diff --git a/python-recipes/vector-search/01_redisvl.ipynb b/python-recipes/vector-search/01_redisvl.ipynb index d0c3611c..5140f242 100644 --- a/python-recipes/vector-search/01_redisvl.ipynb +++ b/python-recipes/vector-search/01_redisvl.ipynb @@ -4431,9 +4431,9 @@ } ], "source": [ - "from redisvl.query import HybridQuery\n", + "from redisvl.query import AggregateHybridQuery\n", "\n", - "hybrid_query = HybridQuery(\n", + "hybrid_query = AggregateHybridQuery(\n", " text=user_query,\n", " text_field_name=\"description\",\n", " text_scorer=\"BM25\",\n", diff --git a/python-recipes/vector-search/02_hybrid_search.ipynb b/python-recipes/vector-search/02_hybrid_search.ipynb index fc9bec04..bfbea784 100644 --- a/python-recipes/vector-search/02_hybrid_search.ipynb +++ b/python-recipes/vector-search/02_hybrid_search.ipynb @@ -9,7 +9,7 @@ "\n", "Hybrid search is all about combining lexical search with semantic vector search to improve result relevancy. This notebook will cover 3 different hybrid search strategies with Redis:\n", "\n", - "1. Linear combination of scores from lexical search (BM25) and vector search (Cosine Distance) with the HybridQuery class\n", + "1. Linear combination of scores from lexical search (BM25) and vector search (Cosine Distance) with the AggregateHybridQuery class\n", "2. Client-Side Reciprocal Rank Fusion (RRF)\n", "3. Client-Side Reranking with a cross encoder model\n", "\n", @@ -653,18 +653,18 @@ "\n", "Now that our search index is populated and ready, we will build out a few different hybrid search techniques in Redis.\n", "\n", - "To start, we will use our `HybridQuery` class that accepts a text string and vector to automatically combine text similarity and vector similarity scores." + "To start, we will use our `AggregateHybridQuery` class that accepts a text string and vector to automatically combine text similarity and vector similarity scores." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## 1. Linear Combination using HybridQuery\n", + "## 1. Linear Combination using AggregateHybridQuery\n", "\n", "The goal of this technique is to calculate a weighted sum of the text similarity score for our provided text search and the cosine distance between vectors calculated via a KNN vector query. Under the hood this is possible in Redis using the [aggregations API](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations/), as of `Redis 7.4.x` (search version `2.10.5`), within a single database call.\n", "\n", - "As of RedisVl 0.5.0 all of this is nicely encapsulated in your `HybridQuery` class, which behaves much like our other query classes." + "As of RedisVl 0.5.0 all of this is nicely encapsulated in your `AggregateHybridQuery` class, which behaves much like our other query classes." ] }, { @@ -681,10 +681,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "First, we will import our `HybridQuery` and understand its parameters.\n", - "At a minimum, the `HybridQuery` needs 4 arguments:\n", + "First, we will import our `AggregateHybridQuery` and understand its parameters.\n", + "At a minimum, the `AggregateHybridQuery` needs 4 arguments:\n", "```python\n", - "query = HybridQuery(\n", + "query = AggregateHybridQuery(\n", " text = \"your query string here\",\n", " text_field_name = \"\",\n", " vector = ,\n", @@ -738,11 +738,11 @@ } ], "source": [ - "from redisvl.query import HybridQuery\n", + "from redisvl.query import AggregateHybridQuery\n", "\n", "vector = model.embed(user_query, as_buffer=True)\n", "\n", - "query = HybridQuery(\n", + "query = AggregateHybridQuery(\n", " text=user_query,\n", " text_field_name=\"description\",\n", " vector=vector,\n", @@ -760,7 +760,7 @@ "metadata": {}, "source": [ "That's it! That is all it takes to perform a hybrid text matching and vector query with RedisVL.\n", - "Of course there are many more configurations and things we can do with the `HybridQuery` class. Let's investigate.\n", + "Of course there are many more configurations and things we can do with the `AggregateHybridQuery` class. Let's investigate.\n", "\n", "First, let's look at just the text query part that is being run:" ] @@ -828,7 +828,7 @@ "# translate our user query to French and use nltk french stopwords\n", "french_query_text = \"Film d'action et d'aventure avec de superbes scènes de combat, des enquêtes criminelles, des super-héros et de la magie\"\n", "\n", - "french_film_query = HybridQuery(\n", + "french_film_query = AggregateHybridQuery(\n", " text=french_query_text,\n", " text_field_name=\"description\",\n", " vector=model.embed(french_query_text, as_buffer=True),\n", @@ -845,7 +845,7 @@ " \"then\", \"there\", \"these\", \"they\", \"this\", \"to\", \"was\", \"will\", \"with\"\n", "])\n", "\n", - "stopwords_query = HybridQuery(\n", + "stopwords_query = AggregateHybridQuery(\n", " text=user_query,\n", " text_field_name=\"description\",\n", " vector=vector,\n", @@ -856,7 +856,7 @@ "print(stopwords_query._build_query_string())\n", "\n", "# don't use any stopwords\n", - "no_stopwords_query = HybridQuery(\n", + "no_stopwords_query = AggregateHybridQuery(\n", " text=user_query,\n", " text_field_name=\"description\",\n", " vector=vector,\n", @@ -919,7 +919,7 @@ } ], "source": [ - "tfidf_query = HybridQuery(\n", + "tfidf_query = AggregateHybridQuery(\n", " text=user_query,\n", " text_field_name=\"description\",\n", " vector=vector,\n", @@ -1333,7 +1333,7 @@ "source": [ "def hybrid_query(text, alpha, num_results) -> List[Dict[str, Any]]:\n", "\n", - " query = HybridQuery(\n", + " query = AggregateHybridQuery(\n", " text,\n", " text_field_name=\"description\",\n", " vector=model.embed(text, as_buffer=True),\n",