Skip to content

Conversation

@Xunzhuo
Copy link
Member

@Xunzhuo Xunzhuo commented Nov 9, 2025

Description

This PR refactors the classification API by removing the deprecated ClassifyCategory method and consolidating all classification to use ClassifyCategoryWithEntropy. It also adds comprehensive embedding-based classification configuration.

Changes Made

Code Refactoring

  • ✅ Removed ClassifyCategory method from classifier.go
  • ✅ Removed classifyCategoryInTree helper method
  • ✅ Integrated keywordEmbeddingClassifier call within ClassifyCategoryWithEntropy
    • Classification flow: keyword classifier → keyword embedding classifier → in-tree classifier → MCP classifier
  • ✅ Removed ClassifyAndSelectBestModel method and its tests
  • ✅ Removed findCategoryForClassification helper method from req_filter_classification.go
  • ✅ Updated all callers to use ClassifyCategoryWithEntropy with 4 return values (category, confidence, reasoningDecision, error)
  • ✅ Updated all test cases to use ClassifyCategoryWithEntropy with proper mock data

Configuration

  • ✅ Added config/intelligent-routing/in-tree/embedding.yaml with comprehensive embedding classifier configuration
    • Includes 4 embedding rules: technical_support, product_inquiry, account_management, general_inquiry
    • Configured with different models (auto, qwen3, gemma) and dimensions (512, 768, 1024)
    • Includes category definitions with model scores and system prompts

Benefits

  1. Unified API: All classification now goes through ClassifyCategoryWithEntropy, providing consistent entropy-based reasoning decisions
  2. Keyword Embedding Integration: The keywordEmbeddingClassifier is now properly integrated into the entropy-based classification flow
  3. Cleaner Code: Removed duplicate classification logic and simplified the codebase
  4. Better Configuration: Added comprehensive embedding-based classification rules for common use cases

Testing

  • ✅ All modified packages compile successfully
  • ✅ Updated test cases to match new API signatures
  • ✅ No IDE errors or warnings (only style suggestions)

Files Changed

  • src/semantic-router/pkg/classification/classifier.go - Removed methods and updated classification flow
  • src/semantic-router/pkg/classification/classifier_test.go - Updated tests
  • src/semantic-router/pkg/extproc/req_filter_classification.go - Removed helper and updated caller
  • src/semantic-router/pkg/services/classification.go - Updated caller
  • config/intelligent-routing/in-tree/embedding.yaml - New configuration file

BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE


  • Make sure the code changes pass the pre-commit checks.
  • Sign-off your commit by using -s when doing git commit
  • Try to classify PRs for easy understanding of the type of changes, such as [Bugfix], [Feat], and [CI].

- Removed ClassifyCategory method and all references, keeping only ClassifyCategoryWithEntropy
- Integrated keywordEmbeddingClassifier call within ClassifyCategoryWithEntropy
- Removed ClassifyAndSelectBestModel method and its tests
- Removed findCategoryForClassification helper method
- Updated all callers to use ClassifyCategoryWithEntropy with 4 return values
- Added embedding classifier configuration in config/intelligent-routing/in-tree/embedding.yaml
- Updated tests to use ClassifyCategoryWithEntropy with proper mock data

This refactoring simplifies the classification API by consolidating to a single
entropy-based classification method and adds comprehensive embedding-based
classification rules configuration.

Signed-off-by: bitliu <bitliu@tencent.com>
@netlify
Copy link

netlify bot commented Nov 9, 2025

Deploy Preview for vllm-semantic-router ready!

Name Link
🔨 Latest commit d4467b4
🔍 Latest deploy log https://app.netlify.com/projects/vllm-semantic-router/deploys/69101591fc3e800008f3fac8
😎 Deploy Preview https://deploy-preview-620--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 Nov 9, 2025

👥 vLLM Semantic Team Notification

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

📁 config

Owners: @rootfs, @Xunzhuo
Files changed:

  • config/intelligent-routing/in-tree/embedding.yaml

📁 src

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

  • src/semantic-router/pkg/classification/classifier.go
  • src/semantic-router/pkg/classification/classifier_test.go
  • src/semantic-router/pkg/config/config.go
  • src/semantic-router/pkg/extproc/req_filter_classification.go
  • src/semantic-router/pkg/services/classification.go

vLLM

🎉 Thanks for your contributions!

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

@rootfs rootfs requested a review from Copilot November 9, 2025 03:07
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 refactors the category classification system by removing the ClassifyCategory method and standardizing on the entropy-based ClassifyCategoryWithEntropy method. This consolidates classification logic to use entropy-based reasoning decisions consistently across the codebase.

Key Changes:

  • Removed the ClassifyCategory and ClassifyAndSelectBestModel methods from the classifier
  • Updated all call sites to use ClassifyCategoryWithEntropy instead
  • Removed the fallback logic in performClassificationAndModelSelection to use simple classification on error
  • Added embedding-based classification support to ClassifyCategoryWithEntropy

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
src/semantic-router/pkg/classification/classifier.go Removed ClassifyCategory, classifyCategoryInTree, and ClassifyAndSelectBestModel methods; added embedding classifier support to ClassifyCategoryWithEntropy
src/semantic-router/pkg/services/classification.go Updated to call ClassifyCategoryWithEntropy instead of ClassifyCategory
src/semantic-router/pkg/extproc/req_filter_classification.go Removed fallback logic and findCategoryForClassification method; simplified error handling to use empty category
src/semantic-router/pkg/classification/classifier_test.go Updated all test cases to use ClassifyCategoryWithEntropy and classifyWithProbsResult instead of ClassifyCategory and classifyResult; removed obsolete test suite for ClassifyAndSelectBestModel
config/intelligent-routing/in-tree/embedding.yaml Added new configuration file for embedding-based classification with keyword rules and model settings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- "troubleshooting steps"
- "error message explanation"
- "setup instructions"
aggregation_mathod: "max" # Options: "max", "avg", "any"
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'aggregation_mathod' to 'aggregation_method'. This typo appears in 4 locations (lines 86, 100, 112, 123) in the new configuration file. Note that the struct tag in src/semantic-router/pkg/config/config.go line 219 also uses this misspelling: yaml:"aggregation_mathod". To fix this completely, both the config file and the struct tag should be corrected together to maintain consistency.

Copilot uses AI. Check for mistakes.
- "availability and stock"
- "product comparison"
- "warranty details"
aggregation_mathod: "avg"
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'aggregation_mathod' to 'aggregation_method'.

Copilot uses AI. Check for mistakes.
- "profile update"
- "subscription management"
- "billing information"
aggregation_mathod: "max"
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'aggregation_mathod' to 'aggregation_method'.

Copilot uses AI. Check for mistakes.
- "information request"
- "help needed"
- "customer service"
aggregation_mathod: "any"
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'aggregation_mathod' to 'aggregation_method'.

Copilot uses AI. Check for mistakes.
rootfs
rootfs previously approved these changes Nov 9, 2025
Signed-off-by: bitliu <bitliu@tencent.com>
@Xunzhuo Xunzhuo merged commit aab9aa7 into main Nov 9, 2025
16 checks passed
@Xunzhuo Xunzhuo deleted the refactor/remove-classify-category-and-add-embedding-config branch November 16, 2025 15:02
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.

4 participants