SemanticRouter considers when making a classification. This can be useful if we want to restrict the scope of possible routes based on some context.
For example, we may have a router with several routes, politics, weather, chitchat, etc. We may want to restrict the scope of the classification to only consider the chitchat route. We can do this by passing a route_filter argument to our SemanticRouter calls like so:
SemanticRouter will only consider the chitchat route for the classification.
Full Example
SemanticRouter. When called, the router will consume text (a query) and output the category (Route) it belongs to — to initialize a SemanticRouter we need our encoder model and a list of routes.
Route objects?
None because no matches were identified.
Demonstrating the Filter Feature
Now, let’s demonstrate the filter feature. We can specify a subset of routes to consider when making a classification. This can be useful if we want to restrict the scope of possible routes based on some context. For example, let’s say we only want to consider the “chitchat” route for a particular query:None because the query doesn’t match the “politics” route well enough to pass the threshold.
