Skip to content

Commit 41ed6ca

Browse files
prep optimizer docs
1 parent b09610b commit 41ed6ca

File tree

6 files changed

+65
-7
lines changed

6 files changed

+65
-7
lines changed

docs/api/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ reranker
2222
cache
2323
session_manager
2424
router
25+
threshold_optimizer
2526
```
2627

docs/api/session_manager.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
LLM Session Manager
33
*******************
44

5-
65
SemanticSessionManager
76
======================
87

docs/api/threshold_optimizer.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
********************
2+
Threshold Optimizers
3+
********************
4+
5+
CacheThresholdOptimizer
6+
=======================
7+
8+
.. _cachethresholdoptimizer_api:
9+
10+
.. currentmodule:: redisvl.utils.optimize.cache
11+
12+
.. autoclass:: CacheThresholdOptimizer
13+
:show-inheritance:
14+
:members:
15+
16+
17+
RouterThresholdOptimizer
18+
========================
19+
20+
.. _routerthresholdoptimizer_api:
21+
22+
.. currentmodule:: redisvl.utils.optimize.router
23+
24+
.. autoclass:: RouterThresholdOptimizer
25+
:show-inheritance:
26+
:members:

docs/user_guide/release_guide/0_5_0_release.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"![Redis](https://redis.io/wp-content/uploads/2024/04/Logotype.svg?auto=webp&quality=85,75&width=120)\n",
8-
"# RedisVL 0.5.0 Overview\n",
7+
"# 0.5.0 Feature Overview\n",
98
"\n",
109
"This notebook provides an overview of what's new with the 0.5.0 release of redisvl. It also highlights changes and potential enhancements for existing usage.\n",
1110
"\n",

redisvl/utils/optimize/cache.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,33 @@ class CacheThresholdOptimizer(BaseThresholdOptimizer):
7676
def __init__(
7777
self,
7878
cache: SemanticCache,
79-
test_dict: List[Dict],
79+
test_dict: List[Dict[str, Any]],
8080
opt_fn: Callable = _grid_search_opt_cache,
8181
eval_metric: str = "f1",
8282
):
83+
"""Initialize the optimizer.
84+
85+
Args:
86+
cache (SemanticCache): The RedisVL SemanticCache instance to optimize.
87+
test_dict (List[Dict[str, Any]]): List of test cases.
88+
opt_fn (Callable): Function to perform optimization. Defaults to
89+
grid search.
90+
eval_metric (str): Evaluation metric for threshold optimization.
91+
Defaults to "f1" score.
92+
93+
.. code-block:: python
94+
95+
# TODO
96+
97+
"""
8398
super().__init__(cache, test_dict, opt_fn, eval_metric)
8499

85100
def optimize(self, **kwargs: Any):
86-
"""Optimize thresholds using the provided optimization function for cache case."""
101+
"""Optimize thresholds using the provided optimization function for cache case.
102+
103+
.. code-block:: python
104+
105+
# TODO
106+
107+
"""
87108
self.opt_fn(self.optimizable, self.test_data, self.eval_metric, **kwargs)

redisvl/utils/optimize/router.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,25 @@ class RouterThresholdOptimizer(BaseThresholdOptimizer):
9595
def __init__(
9696
self,
9797
router: SemanticRouter,
98-
test_dict: List[Dict],
98+
test_dict: List[Dict[str, Any]],
9999
opt_fn: Callable = _random_search_opt_router,
100100
eval_metric: str = "f1",
101101
):
102+
"""
103+
# TODO
104+
105+
.. code-block:: python
106+
107+
# TODO
108+
"""
102109
super().__init__(router, test_dict, opt_fn, eval_metric)
103110

104111
def optimize(self, **kwargs: Any):
105-
"""Optimize thresholds using the provided optimization function for router case."""
112+
"""Optimize thresholds using the provided optimization function for router case.
113+
114+
.. code-block:: python
115+
116+
# TODO
117+
"""
106118
qrels = _format_qrels(self.test_data)
107119
self.opt_fn(self.optimizable, self.test_data, qrels, self.eval_metric, **kwargs)

0 commit comments

Comments
 (0)