feat(routing): Implement in-tree keyword-based routing#538
feat(routing): Implement in-tree keyword-based routing#538srini-abhiram wants to merge 5 commits intovllm-project:mainfrom
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.
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 <aukovyps@163.com> Signed-off-by: Srinivas A <56465971+srini-abhiram@users.noreply.github.com>
Signed-off-by: yuluo-yx <yuluo08290126@gmail.com> Signed-off-by: Srinivas A <56465971+srini-abhiram@users.noreply.github.com>
- 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 <56465971+srini-abhiram@users.noreply.github.com>
- 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 <56465971+srini-abhiram@users.noreply.github.com>
- 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 <56465971+srini-abhiram@users.noreply.github.com>
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