Skip to content

Conversation

@yuezhu1
Copy link
Collaborator

@yuezhu1 yuezhu1 commented Nov 24, 2025

add unified jailbreak classifier with LazyLock optimization and bench

  • Implement unified jailbreak model factory with auto-detection from config.json

    • Supports ModernBERT, DeBERTa V3, and Qwen3Guard models
    • Automatic architecture detection and model loading
  • Performance optimizations:

    • Use LazyLock for static default labels (zero-cost after init)
    • Use parking_lot::Mutex instead of std::sync::Mutex for Qwen3Guard
    • Lock-free classification for ModernBERT and DeBERTa (Arc-wrapped)
    • Early lock release in Qwen3Guard to minimize hold time
  • Add comprehensive Go benchmark suite:

    • Test all jailbreak models (ModernBERT, DeBERTa, Unified, Qwen3Guard)
    • Measure accuracy, confidence, and latency percentiles (p50/p95/p99)
    • Test both CPU and GPU performance
    • Benchmark results show DeBERTa V3 achieves 95% accuracy
  • Update FFI bindings:

    • Add init_unified_jailbreak_classifier and classify_unified_jailbreak_text
    • Update ClassificationResult to include label field
    • Rename 'class' to 'predicted_class' for consistency
  • Add HuggingFace model ID support in unified factory

    • Auto-fetch config.json from HuggingFace Hub
    • Support both local paths and HF model IDs
  • Add unit tests for unified jailbreak classifier

    • Tests in semantic-router_test.go, config_test.go, extproc_test.go
    • Fix test compilation errors with proper struct field usage
  • Update Go interfaces to use unified classifier by default

    • Deprecate useModernBERT flag in favor of auto-detection

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].
Detailed Checklist (Click to Expand)

Thank you for your contribution to semantic-router! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Feat] for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).
  • [Router] for changes to the vllm_router (e.g., routing algorithm, router observability, etc.).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • Pass all linter checks. Please use pre-commit to format your code. See README.md for installation.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Please include sufficient tests to ensure the change is stay correct and robust. This includes both unit tests and integration tests.

DCO and Signed-off-by

When contributing changes to this project, you must agree to the DCO. Commits must include a Signed-off-by: header which certifies agreement with the terms of the DCO.

Using -s with git commit will automatically add this header.

What to Expect for the Reviews

@netlify
Copy link

netlify bot commented Nov 24, 2025

Deploy Preview for vllm-semantic-router ready!

Name Link
🔨 Latest commit 9cc3049
🔍 Latest deploy log https://app.netlify.com/projects/vllm-semantic-router/deploys/6923f397128f1200080214b2
😎 Deploy Preview https://deploy-preview-727--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 24, 2025

👥 vLLM Semantic Team Notification

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

📁 bench

Owners: @yuezhu1, @Xunzhuo
Files changed:

  • bench/.gitignore
  • bench/Makefile
  • bench/comprehensive_jailbreak_bench.go
  • bench/go.mod
  • bench/jailbreak_bench_test.go
  • bench/run_jailbreak_bench.sh

📁 candle-binding

Owners: @rootfs
Files changed:

  • candle-binding/src/model_architectures/jailbreak_factory.rs
  • candle-binding/semantic-router.go
  • candle-binding/semantic-router_test.go
  • candle-binding/src/ffi/classify.rs
  • candle-binding/src/ffi/init.rs
  • candle-binding/src/model_architectures/mod.rs
  • candle-binding/src/model_architectures/traditional/deberta_v3_test.rs

📁 Root Directory

Owners: @rootfs, @Xunzhuo
Files changed:

  • examples/jailbreak-unified-example.yaml
  • examples/jailbreak_unified_test.go

📁 deploy

Owners: @rootfs, @Xunzhuo
Files changed:

  • deploy/kubernetes/istio/config.yaml
  • deploy/kubernetes/istio/vLlama3.yaml
  • deploy/kubernetes/istio/vPhi4.yaml
  • deploy/openshift/openwebui/pvc.yaml

📁 src

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

  • src/semantic-router/pkg/classification/classifier.go
  • src/semantic-router/pkg/config/config.go
  • src/semantic-router/pkg/config/config_test.go
  • src/semantic-router/pkg/config/helper.go
  • src/semantic-router/pkg/extproc/extproc_test.go

📁 website

Owners: @Xunzhuo, @rootfs, @yuluo-yx
Files changed:

  • website/package-lock.json
  • website/src/theme/Root.tsx

vLLM

🎉 Thanks for your contributions!

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

@github-actions github-actions bot deleted a comment from codecov-commenter Nov 24, 2025
… benchmarks

- Implement unified jailbreak model factory with auto-detection from config.json
  - Supports ModernBERT, DeBERTa V3, and Qwen3Guard models
  - Automatic architecture detection and model loading

- Performance optimizations:
  - Use LazyLock for static default labels (zero-cost after init)
  - Use parking_lot::Mutex instead of std::sync::Mutex for Qwen3Guard
  - Lock-free classification for ModernBERT and DeBERTa (Arc-wrapped)
  - Early lock release in Qwen3Guard to minimize hold time

- Add comprehensive Go benchmark suite:
  - Test all jailbreak models (ModernBERT, DeBERTa, Unified, Qwen3Guard)
  - Measure accuracy, confidence, and latency percentiles (p50/p95/p99)
  - Test both CPU and GPU performance
  - Benchmark results show DeBERTa V3 achieves 95% accuracy

- Update FFI bindings:
  - Add init_unified_jailbreak_classifier and classify_unified_jailbreak_text
  - Update ClassificationResult to include label field
  - Rename 'class' to 'predicted_class' for consistency

- Add HuggingFace model ID support in unified factory
  - Auto-fetch config.json from HuggingFace Hub
  - Support both local paths and HF model IDs

- Add unit tests for unified jailbreak classifier
  - Tests in semantic-router_test.go, config_test.go, extproc_test.go
  - Fix test compilation errors with proper struct field usage

- Update Go interfaces to use unified classifier by default
  - Deprecate useModernBERT flag in favor of auto-detection

Signed-off-by: Yue Zhu <16687552+yuezhu1@users.noreply.github.com>
@yuezhu1 yuezhu1 force-pushed the feat/unified_jailbreak_classifier branch from 00353af to 9cc3049 Compare November 24, 2025 05:56
@github-actions github-actions bot deleted a comment from codecov-commenter Nov 24, 2025
@rootfs rootfs requested a review from Copilot November 24, 2025 14:23
Copilot finished reviewing on behalf of rootfs November 24, 2025 14:55
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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