Skip to content

Conversation

@srini-abhiram
Copy link
Contributor

What this PR does / why we need it:

  • 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.

Which issue(s) this PR fixes:
Fixes #364

Unit tests results: Passed

@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for vllm-semantic-router ready!

Name Link
🔨 Latest commit 68d1c3b
🔍 Latest deploy log https://app.netlify.com/projects/vllm-semantic-router/deploys/6900545d24623f0008dbe673
😎 Deploy Preview https://deploy-preview-538--vllm-semantic-router.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

github-actions bot commented Oct 27, 2025

👥 vLLM Semantic Team Notification

The following members have been identified for the changed files in this PR and have been automatically assigned:

📁 src

Owners: @rootfs, @Xunzhuo, @wangchen615
Files changed:

  • src/semantic-router/pkg/utils/classification/benchmark_test.go
  • src/semantic-router/pkg/utils/classification/keyword_classifier.go
  • src/semantic-router/pkg/utils/classification/keyword_classifier_test.go
  • src/semantic-router/pkg/config/config.go
  • src/semantic-router/pkg/utils/classification/classifier.go

vLLM

🎉 Thanks for your contributions!

This comment was automatically generated based on the OWNER files in the repository.

@srini-abhiram
Copy link
Contributor Author

I hope the implementation is as per issue. I have assumed most of it, please correct me if Im wrong.

@rootfs
Copy link
Collaborator

rootfs commented Oct 27, 2025

@srini-abhiram thanks! can you sign DCO and fix pre-commit?

Ensure you have a local copy of your branch by [checking out the pull request locally via command line](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally).
In your local branch, run: git rebase HEAD~2 --signoff
Force push your changes to overwrite the branch: git push --force-with-lease origin issue-364

@rootfs rootfs requested a review from Copilot October 27, 2025 13:40
Copy link
Contributor

Copilot AI left a 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 KeywordClassifier with 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.

OneZero-Y and others added 5 commits October 28, 2025 10:55
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]>
@srini-abhiram
Copy link
Contributor Author

I have signed off the wrong commits, let me put the changes in a fresh branch and create a new PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Prompt Classification] Implement In-Tree Keyword Matching

6 participants