diff --git a/bench/hallucination/config-7b.yaml b/bench/hallucination/config-7b.yaml index 88f46031cf..dfeaa29e4c 100644 --- a/bench/hallucination/config-7b.yaml +++ b/bench/hallucination/config-7b.yaml @@ -33,7 +33,6 @@ hallucination_mitigation: model_id: "models/halugate-sentinel" threshold: 0.6 use_cpu: true - mapping_path: "models/halugate-sentinel/fact_check_mapping.json" # Hallucination detector: verifies if LLM response is grounded in context # Using large model (395M params) for better accuracy diff --git a/bench/hallucination/config.yaml b/bench/hallucination/config.yaml index 29f8edfa61..487940974d 100644 --- a/bench/hallucination/config.yaml +++ b/bench/hallucination/config.yaml @@ -33,7 +33,6 @@ hallucination_mitigation: model_id: "models/halugate-sentinel" threshold: 0.6 use_cpu: true - mapping_path: "models/halugate-sentinel/fact_check_mapping.json" # Hallucination detector: verifies if LLM response is grounded in context # Using large model (395M params) for better accuracy diff --git a/config/config.prompt_guard.vllm.yaml b/config/prompt-guard/prompt_guard.yaml similarity index 100% rename from config/config.prompt_guard.vllm.yaml rename to config/prompt-guard/prompt_guard.yaml diff --git a/config/config.redis.yaml b/config/semantic-cache/config.redis.yaml similarity index 100% rename from config/config.redis.yaml rename to config/semantic-cache/config.redis.yaml diff --git a/config/testing/config.hallucination.yaml b/config/testing/config.hallucination.yaml index 14545ec29c..9207e4112c 100644 --- a/config/testing/config.hallucination.yaml +++ b/config/testing/config.hallucination.yaml @@ -42,7 +42,6 @@ hallucination_mitigation: model_id: "models/halugate-sentinel" threshold: 0.6 use_cpu: true - mapping_path: "models/halugate-sentinel/fact_check_mapping.json" # Hallucination detector: verifies if LLM response is grounded in context hallucination_model: diff --git a/src/semantic-router/pkg/classification/fact_check_classifier.go b/src/semantic-router/pkg/classification/fact_check_classifier.go index 1f46fcf222..640b0869cc 100644 --- a/src/semantic-router/pkg/classification/fact_check_classifier.go +++ b/src/semantic-router/pkg/classification/fact_check_classifier.go @@ -49,37 +49,16 @@ func (c *FactCheckClassifier) Initialize() error { return nil } - // Load mapping if configured - if c.config.MappingPath != "" { - mapping, err := LoadFactCheckMapping(c.config.MappingPath) - if err != nil { - logging.Warnf("Failed to load fact-check mapping from %s: %v, using defaults", c.config.MappingPath, err) - // Create default mapping - c.mapping = &FactCheckMapping{ - LabelToIdx: map[string]int{ - FactCheckLabelNotNeeded: 0, - FactCheckLabelNeeded: 1, - }, - IdxToLabel: map[string]string{ - "0": FactCheckLabelNotNeeded, - "1": FactCheckLabelNeeded, - }, - } - } else { - c.mapping = mapping - } - } else { - // Create default mapping - c.mapping = &FactCheckMapping{ - LabelToIdx: map[string]int{ - FactCheckLabelNotNeeded: 0, - FactCheckLabelNeeded: 1, - }, - IdxToLabel: map[string]string{ - "0": FactCheckLabelNotNeeded, - "1": FactCheckLabelNeeded, - }, - } + // Use default mapping (no external mapping file needed) + c.mapping = &FactCheckMapping{ + LabelToIdx: map[string]int{ + FactCheckLabelNotNeeded: 0, + FactCheckLabelNeeded: 1, + }, + IdxToLabel: map[string]string{ + "0": FactCheckLabelNotNeeded, + "1": FactCheckLabelNeeded, + }, } // Initialize ML model - ModelID is required diff --git a/src/semantic-router/pkg/classification/hallucination_test.go b/src/semantic-router/pkg/classification/hallucination_test.go index 4d4678a4b0..7b78e259a2 100644 --- a/src/semantic-router/pkg/classification/hallucination_test.go +++ b/src/semantic-router/pkg/classification/hallucination_test.go @@ -480,7 +480,6 @@ var _ = Describe("Classifier with Hallucination Mitigation", func() { cfg = &config.RouterConfig{} cfg.HallucinationMitigation.Enabled = true cfg.HallucinationMitigation.FactCheckModel.ModelID = "test-model" - cfg.HallucinationMitigation.FactCheckModel.MappingPath = "test-mapping.json" classifier = &Classifier{Config: cfg} Expect(classifier.IsFactCheckEnabled()).To(BeTrue()) diff --git a/src/semantic-router/pkg/config/config.go b/src/semantic-router/pkg/config/config.go index fcde8c42a4..e72351cac9 100644 --- a/src/semantic-router/pkg/config/config.go +++ b/src/semantic-router/pkg/config/config.go @@ -526,9 +526,6 @@ type FactCheckModelConfig struct { // Use CPU for inference UseCPU bool `yaml:"use_cpu"` - - // Path to fact-check label mapping file (JSON format) - MappingPath string `yaml:"mapping_path"` } // HallucinationModelConfig represents configuration for hallucination detection model diff --git a/src/semantic-router/pkg/config/config_test.go b/src/semantic-router/pkg/config/config_test.go index fa57aa7e03..a8548ec9c0 100644 --- a/src/semantic-router/pkg/config/config_test.go +++ b/src/semantic-router/pkg/config/config_test.go @@ -2426,7 +2426,6 @@ hallucination_mitigation: model_id: "models/fact_check_classifier" threshold: 0.75 use_cpu: true - mapping_path: "config/hallucination/fact_check_mapping.json" hallucination_model: model_id: "models/hallucination_detect_modernbert" threshold: 0.6 @@ -2445,7 +2444,6 @@ hallucination_mitigation: Expect(cfg.HallucinationMitigation.FactCheckModel.ModelID).To(Equal("models/fact_check_classifier")) Expect(cfg.HallucinationMitigation.FactCheckModel.Threshold).To(Equal(float32(0.75))) Expect(cfg.HallucinationMitigation.FactCheckModel.UseCPU).To(BeTrue()) - Expect(cfg.HallucinationMitigation.FactCheckModel.MappingPath).To(Equal("config/hallucination/fact_check_mapping.json")) Expect(cfg.HallucinationMitigation.HallucinationModel.ModelID).To(Equal("models/hallucination_detect_modernbert")) Expect(cfg.HallucinationMitigation.HallucinationModel.Threshold).To(Equal(float32(0.6))) Expect(cfg.HallucinationMitigation.HallucinationModel.UseCPU).To(BeTrue()) @@ -2544,7 +2542,6 @@ default_model: "test-model" cfg := &RouterConfig{} cfg.HallucinationMitigation.Enabled = true cfg.HallucinationMitigation.FactCheckModel.ModelID = "models/fact_check" - cfg.HallucinationMitigation.FactCheckModel.MappingPath = "config/mapping.json" Expect(cfg.IsFactCheckClassifierEnabled()).To(BeTrue()) }) @@ -2556,7 +2553,6 @@ default_model: "test-model" {Name: "no_fact_check_needed", Description: "Query does not need fact verification"}, } cfg.HallucinationMitigation.FactCheckModel.ModelID = "models/fact_check" - cfg.HallucinationMitigation.FactCheckModel.MappingPath = "config/mapping.json" Expect(cfg.IsFactCheckClassifierEnabled()).To(BeTrue()) }) @@ -2565,7 +2561,6 @@ default_model: "test-model" cfg := &RouterConfig{} cfg.HallucinationMitigation.Enabled = false cfg.HallucinationMitigation.FactCheckModel.ModelID = "models/fact_check" - cfg.HallucinationMitigation.FactCheckModel.MappingPath = "config/mapping.json" Expect(cfg.IsFactCheckClassifierEnabled()).To(BeFalse()) }) @@ -2573,15 +2568,6 @@ default_model: "test-model" It("should return false when model_id is missing", func() { cfg := &RouterConfig{} cfg.HallucinationMitigation.Enabled = true - cfg.HallucinationMitigation.FactCheckModel.MappingPath = "config/mapping.json" - - Expect(cfg.IsFactCheckClassifierEnabled()).To(BeFalse()) - }) - - It("should return false when mapping_path is missing", func() { - cfg := &RouterConfig{} - cfg.HallucinationMitigation.Enabled = true - cfg.HallucinationMitigation.FactCheckModel.ModelID = "models/fact_check" Expect(cfg.IsFactCheckClassifierEnabled()).To(BeFalse()) }) diff --git a/src/semantic-router/pkg/config/helper.go b/src/semantic-router/pkg/config/helper.go index 078dc7ddc7..668375d390 100644 --- a/src/semantic-router/pkg/config/helper.go +++ b/src/semantic-router/pkg/config/helper.go @@ -452,16 +452,14 @@ func (c *RouterConfig) IsFactCheckClassifierEnabled() bool { // Check new fact_check_rules config first if len(c.FactCheckRules) > 0 { // For new signal config, still need the model from HallucinationMitigation - return c.HallucinationMitigation.FactCheckModel.ModelID != "" && - c.HallucinationMitigation.FactCheckModel.MappingPath != "" + return c.HallucinationMitigation.FactCheckModel.ModelID != "" } // Fall back to legacy HallucinationMitigation config if !c.HallucinationMitigation.Enabled { return false } - return c.HallucinationMitigation.FactCheckModel.ModelID != "" && - c.HallucinationMitigation.FactCheckModel.MappingPath != "" + return c.HallucinationMitigation.FactCheckModel.ModelID != "" } // GetFactCheckRules returns all configured fact_check_rules