Support for setting top_k for HybridRouteLayer?
Closed this issue · 1 comments
andreped commented
I see that top_k=5
is hardcoded for the HybridRouteLayer
class:
Which is possible to set through the _query
method:
I believe being able to set top_k
would be of value to achieve better performance in some use cases.
andreped commented
The feature has been merged but has yet to be part of a release. For now, install from source to get feature.
Below is an example on how to set top_k
:
from semantic_router.encoders import AzureOpenAIEncoder, TfidfEncoder
from semantic_router.hybrid_layer import HybridRouteLayer
model = HybridRouteLayer(
encoder=AzureOpenAIEncoder(...),
sparse_encoder=TfidfEncoder(),
routes=routes,
alpha=0.3, # default = 0.3
top_k=3, # default = 5
)