Skip to content

Commit e48106c

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/RAAE-1240/multimodal-embeddings
# Conflicts: # docs/api/query.rst # docs/user_guide/11_advanced_queries.ipynb # redisvl/index/index.py # redisvl/query/hybrid.py # tests/integration/test_hybrid.py # tests/unit/test_hybrid_types.py # uv.lock
2 parents e8d00ad + b5ba960 commit e48106c

File tree

16 files changed

+387
-488
lines changed

16 files changed

+387
-488
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ llmcache = SemanticCache(
276276
name="llmcache",
277277
ttl=360,
278278
redis_url="redis://localhost:6379",
279-
distance_threshold=0.1
279+
distance_threshold=0.1 # Redis COSINE distance [0-2], lower is stricter
280280
)
281281
282282
# store user queries and LLM responses in the semantic cache

docs/api/query.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ AggregateHybridQuery
124124
Using query-time stopwords with index-level ``STOPWORDS 0`` is counterproductive.
125125

126126
.. note::
127-
:class:`HybridQuery` and :class:`AggregateHybridQuery` apply linear combination inconsistently. :class:`HybridQuery` uses ``linear_alpha`` to weight the text score and ``linear_beta`` to weight the vector score. :class:`AggregateHybridQuery` uses ``alpha`` to weight the vector score and ``beta`` to weight the text score.
127+
:class:`HybridQuery` and :class:`AggregateHybridQuery` apply linear combination inconsistently. :class:`HybridQuery` uses ``linear_alpha`` to weight the text score, while :class:`AggregateHybridQuery` uses ``alpha`` to weight the vector score. When switching between the two classes, take care to revise your ``alpha`` setting.
128128

129129
.. note::
130130
**Runtime Parameters for Hybrid Queries**
@@ -139,15 +139,14 @@ AggregateHybridQuery
139139

140140
.. code-block:: python
141141
142-
from redisvl.query.hybrid import HybridQuery
142+
from redisvl.query import HybridQuery
143143
144144
query = HybridQuery(
145145
text="query string",
146146
text_field_name="description",
147147
vector=[0.1, 0.2, 0.3],
148148
vector_field_name="embedding",
149149
vector_search_method="KNN",
150-
knn_k=10,
151150
knn_ef_runtime=150, # Runtime parameters work with HybridQuery
152151
return_fields=["description"],
153152
num_results=10,
@@ -171,7 +170,7 @@ HybridQuery
171170
Using query-time stopwords with index-level ``STOPWORDS 0`` is counterproductive.
172171

173172
.. note::
174-
:class:`HybridQuery` and :class:`AggregateHybridQuery` apply linear combination inconsistently. :class:`HybridQuery` uses ``linear_alpha`` to weight the text score and ``linear_beta`` to weight the vector score. :class:`AggregateHybridQuery` uses ``alpha`` to weight the vector score and ``beta`` to weight the text score.
173+
:class:`HybridQuery` and :class:`AggregateHybridQuery` apply linear combination inconsistently. :class:`HybridQuery` uses ``linear_alpha`` to weight the text score, while :class:`AggregateHybridQuery` uses ``alpha`` to weight the vector score. When switching between the two classes, take care to revise your ``alpha`` setting.
175174

176175
TextQuery
177176
================

docs/user_guide/03_llmcache.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"llmcache = SemanticCache(\n",
104104
" name=\"llmcache\", # underlying search index name\n",
105105
" redis_url=\"redis://localhost:6379\", # redis connection url string\n",
106-
" distance_threshold=0.1, # semantic cache distance threshold\n",
106+
" distance_threshold=0.1, # semantic cache distance threshold (Redis COSINE [0-2], lower is stricter)\n",
107107
" vectorizer=HFTextVectorizer(\"redis/langcache-embed-v1\"), # embedding model\n",
108108
")"
109109
]
@@ -312,7 +312,9 @@
312312
"## Customize the Distance Threshold\n",
313313
"\n",
314314
"For most use cases, the right semantic similarity threshold is not a fixed quantity. Depending on the choice of embedding model,\n",
315-
"the properties of the input query, and even business use case -- the threshold might need to change. \n",
315+
"the properties of the input query, and even business use case -- the threshold might need to change.\n",
316+
"\n",
317+
"The distance threshold uses Redis COSINE distance units [0-2], where 0 means identical and 2 means completely different.\n",
316318
"\n",
317319
"Fortunately, you can seamlessly adjust the threshold at any point like below:"
318320
]
@@ -323,7 +325,7 @@
323325
"metadata": {},
324326
"outputs": [],
325327
"source": [
326-
"# Widen the semantic distance threshold\n",
328+
"# Widen the semantic distance threshold (allow less similar matches)\n",
327329
"llmcache.set_threshold(0.5)"
328330
]
329331
},
@@ -930,4 +932,4 @@
930932
},
931933
"nbformat": 4,
932934
"nbformat_minor": 2
933-
}
935+
}

docs/user_guide/07_message_history.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
"source": [
277277
"You can adjust the degree of semantic similarity needed to be included in your context.\n",
278278
"\n",
279-
"Setting a distance threshold close to 0.0 will require an exact semantic match, while a distance threshold of 1.0 will include everything."
279+
"Setting a distance threshold close to 0.0 will require an exact semantic match, while a distance threshold of 2.0 will include everything (Redis COSINE distance range is [0-2])."
280280
]
281281
},
282282
{

docs/user_guide/08_semantic_router.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"route. The incoming query from a user needs to be semantically similar to one or\n",
2828
"more of the references in order to \"match\" on the route.\n",
2929
"\n",
30-
"Additionally, each route has a `distance_threshold` which determines the maximum distance between the query and the reference for the query to be routed to the route. This value is unique to each route."
30+
"Additionally, each route has a `distance_threshold` which determines the maximum distance between the query and the reference for the query to be routed to the route. This value is unique to each route and uses Redis COSINE distance units (0-2], where lower values require stricter matching."
3131
]
3232
},
3333
{

0 commit comments

Comments
 (0)