-
Notifications
You must be signed in to change notification settings - Fork 302
feat(routing): Implement in-tree keyword-based routing #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for vllm-semantic-router ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
👥 vLLM Semantic Team NotificationThe following members have been identified for the changed files in this PR and have been automatically assigned: 📁
|
|
I hope the implementation is as per issue. I have assumed most of it, please correct me if Im wrong. |
|
@srini-abhiram thanks! can you sign DCO and fix pre-commit? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a keyword-based routing mechanism that provides fast-path classification before falling back to model-based inference. The keyword classifier supports AND, OR, and NOR logical operators with configurable case sensitivity, allowing the router to quickly match simple, predefined routes without expensive model inference.
Key Changes:
- Introduced
KeywordClassifierwith support for AND, OR, and NOR operators - Modified the classification pipeline to check keyword rules before model-based classification
- Added configuration support for keyword rules in the router config
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
keyword_classifier.go |
Implements the core keyword matching logic with operator support |
keyword_classifier_test.go |
Unit tests covering all operator types and case sensitivity |
benchmark_test.go |
Performance benchmarks for keyword classification |
classifier.go |
Integrates keyword classifier into the classification pipeline |
config.go |
Adds KeywordRule struct and configuration field |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/semantic-router/pkg/utils/classification/keyword_classifier_test.go
Outdated
Show resolved
Hide resolved
src/semantic-router/pkg/utils/classification/keyword_classifier_test.go
Outdated
Show resolved
Hide resolved
src/semantic-router/pkg/utils/classification/keyword_classifier_test.go
Outdated
Show resolved
Hide resolved
Signed-off-by: OneZero-Y <[email protected]> Signed-off-by: Srinivas A <[email protected]>
Signed-off-by: yuluo-yx <[email protected]> Signed-off-by: Srinivas A <[email protected]>
- Provides a fast-path classification mechanism using keyword matching. This allows the router to bypass expensive model inference for simple, predefined routes. - The new `KeywordClassifier` supports `AND`, `OR`, and `NOR` operators with configurable case sensitivity. - It is executed before model-based classifiers to ensure an early exit on a match. - Rules are defined in the main configuration file under a new `keyword_rules` section. - Add Unit tests for the keyword classifier. Signed-off-by: Srinivas A <[email protected]>
- Matched keywords are now logged for enhanced observability. - Corrected and passed all unit tests for the keyword classifier. - Introduced performance benchmarks. Signed-off-by: Srinivas A <[email protected]>
- Add a warning log for unsupported operators in KeywordClassifier. - Update and clarify test cases to better reflect NOR rule fallback behavior and simplify test logic. Signed-off-by: Srinivas A <[email protected]>
5dfc279 to
68d1c3b
Compare
|
I have signed off the wrong commits, let me put the changes in a fresh branch and create a new PR |

What this PR does / why we need it:
KeywordClassifiersupportsAND,OR, andNORoperators with configurable case sensitivity.keyword_rulessection.Which issue(s) this PR fixes:
Fixes #364
Unit tests results: Passed