Commit 9cc3049
committed
feat: add unified jailbreak classifier with LazyLock optimization and 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 <[email protected]>1 parent c3ce62e commit 9cc3049
File tree
26 files changed
+3073
-56
lines changed- bench
- candle-binding
- src
- ffi
- model_architectures
- traditional
- deploy
- kubernetes/istio
- openshift/openwebui
- examples
- src/semantic-router/pkg
- classification
- config
- extproc
- website
- src/theme
26 files changed
+3073
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
0 commit comments