Skip to content

Commit 4c9bc0c

Browse files
committed
fix(classifier): fix LoRA classifier fallback and update E2E configs
This commit fixes a critical bug in LoRA intent classifier fallback logic and updates E2E/deployment configs to use LoRA intent classification, following the pattern established in PR #709 for PII detection. Changes: 1. Fixed LoRA classifier fallback in classify_candle_bert_text - LoRA errors now fall through to Traditional BERT instead of returning - Ensures backward compatibility when LoRA models fail 2. Updated E2E and deployment configs to use LoRA intent classifier - e2e/profiles: ai-gateway, dynamic-config - deploy/kubernetes/aibrix: semantic-router-values - deploy/helm: semantic-router values + model download list 3. Fixed gofumpt formatting in lora_auto_detection_test.go Fixes #724 Signed-off-by: $(git config user.name) <$(git config user.email)> Signed-off-by: Yossi Ovadia <[email protected]>
1 parent d5a381e commit 4c9bc0c

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

candle-binding/src/ffi/classify.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,11 @@ pub extern "C" fn classify_candle_bert_text(text: *const c_char) -> Classificati
709709
};
710710
}
711711
Err(e) => {
712-
eprintln!("LoRA intent classifier failed: {}", e);
713-
return default_result;
712+
eprintln!(
713+
"LoRA intent classifier error: {}, falling back to Traditional BERT",
714+
e
715+
);
716+
// Don't return - fall through to Traditional BERT classifier
714717
}
715718
}
716719
}

deploy/helm/semantic-router/values.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ initContainer:
159159
repo: Qwen/Qwen3-Embedding-0.6B
160160
- name: all-MiniLM-L12-v2
161161
repo: sentence-transformers/all-MiniLM-L12-v2
162+
- name: lora_intent_classifier_bert-base-uncased_model
163+
repo: LLM-Semantic-Router/lora_intent_classifier_bert-base-uncased_model
162164
- name: category_classifier_modernbert-base_model
163165
repo: LLM-Semantic-Router/category_classifier_modernbert-base_model
164166
- name: pii_classifier_modernbert-base_model
@@ -272,11 +274,11 @@ config:
272274
# Classifier configuration
273275
classifier:
274276
category_model:
275-
model_id: "models/category_classifier_modernbert-base_model"
276-
use_modernbert: true
277+
model_id: "models/lora_intent_classifier_bert-base-uncased_model"
278+
use_modernbert: false # Use LoRA intent classifier with auto-detection
277279
threshold: 0.6
278280
use_cpu: true
279-
category_mapping_path: "models/category_classifier_modernbert-base_model/category_mapping.json"
281+
category_mapping_path: "models/lora_intent_classifier_bert-base-uncased_model/category_mapping.json"
280282
pii_model:
281283
model_id: "models/pii_classifier_modernbert-base_presidio_token_model"
282284
use_modernbert: true

deploy/kubernetes/aibrix/semantic-router-values/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,11 @@ config:
431431
# Classifier configuration
432432
classifier:
433433
category_model:
434-
model_id: "models/category_classifier_modernbert-base_model"
435-
use_modernbert: true
434+
model_id: "models/lora_intent_classifier_bert-base-uncased_model"
435+
use_modernbert: false # Use LoRA intent classifier with auto-detection
436436
threshold: 0.6
437437
use_cpu: true
438-
category_mapping_path: "models/category_classifier_modernbert-base_model/category_mapping.json"
438+
category_mapping_path: "models/lora_intent_classifier_bert-base-uncased_model/category_mapping.json"
439439
pii_model:
440440
# Support both traditional (modernbert) and LoRA-based PII detection
441441
# When model_type is "auto", the system will auto-detect LoRA configuration

e2e/profiles/ai-gateway/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,11 @@ config:
461461
# Classifier configuration
462462
classifier:
463463
category_model:
464-
model_id: "models/category_classifier_modernbert-base_model"
465-
use_modernbert: true
464+
model_id: "models/lora_intent_classifier_bert-base-uncased_model"
465+
use_modernbert: false # Use LoRA intent classifier with auto-detection
466466
threshold: 0.6
467467
use_cpu: true
468-
category_mapping_path: "models/category_classifier_modernbert-base_model/category_mapping.json"
468+
category_mapping_path: "models/lora_intent_classifier_bert-base-uncased_model/category_mapping.json"
469469
pii_model:
470470
# Support both traditional (modernbert) and LoRA-based PII detection
471471
# When model_type is "auto", the system will auto-detect LoRA configuration

e2e/profiles/dynamic-config/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ config:
4242

4343
classifier:
4444
category_model:
45-
model_id: "models/category_classifier_modernbert-base_model"
46-
use_modernbert: true
45+
model_id: "models/lora_intent_classifier_bert-base-uncased_model"
46+
use_modernbert: false # Use LoRA intent classifier with auto-detection
4747
threshold: 0.6
4848
use_cpu: true
49-
category_mapping_path: "models/category_classifier_modernbert-base_model/category_mapping.json"
49+
category_mapping_path: "models/lora_intent_classifier_bert-base-uncased_model/category_mapping.json"
5050
pii_model:
5151
model_id: "models/lora_pii_detector_bert-base-uncased_model"
5252
use_modernbert: false # Use LoRA PII model with auto-detection

src/semantic-router/pkg/classification/lora_auto_detection_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func TestIntentClassificationLoRAAutoDetection(t *testing.T) {
3434

3535
// Try to initialize - should SUCCESS with LoRA auto-detection
3636
err := initializer.Init(cfg.ModelID, cfg.UseCPU, numClasses)
37-
3837
if err != nil {
3938
t.Errorf("Auto-detection failed: %v", err)
4039
return

0 commit comments

Comments
 (0)