Spaces:
Paused
Paused
lanny xu commited on
Commit ·
543b684
1
Parent(s): a93e2b1
delete vectara
Browse files- hallucination_config.py +3 -3
- hallucination_detector.py +2 -4
hallucination_config.py
CHANGED
|
@@ -3,9 +3,9 @@ Hallucination Detector Configuration
|
|
| 3 |
Configure which detection method to use
|
| 4 |
"""
|
| 5 |
|
| 6 |
-
# Detection method: 'vectara', 'nli',
|
| 7 |
-
#
|
| 8 |
-
HALLUCINATION_DETECTION_METHOD = "
|
| 9 |
|
| 10 |
# Thresholds
|
| 11 |
VECTARA_HALLUCINATION_THRESHOLD = 0.5 # Score above this = hallucination
|
|
|
|
| 3 |
Configure which detection method to use
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
# Detection method: 'vectara', 'nli', or 'hybrid' (recommended)
|
| 7 |
+
# 使用 'nli' 可以完全避免 Vectara 权限问题
|
| 8 |
+
HALLUCINATION_DETECTION_METHOD = "nli"
|
| 9 |
|
| 10 |
# Thresholds
|
| 11 |
VECTARA_HALLUCINATION_THRESHOLD = 0.5 # Score above this = hallucination
|
hallucination_detector.py
CHANGED
|
@@ -390,12 +390,12 @@ class HybridHallucinationDetector:
|
|
| 390 |
return "no" if result['has_hallucination'] else "yes"
|
| 391 |
|
| 392 |
|
| 393 |
-
def initialize_hallucination_detector(method: str = "
|
| 394 |
"""
|
| 395 |
初始化幻觉检测器
|
| 396 |
|
| 397 |
Args:
|
| 398 |
-
method: 'vectara', 'nli',
|
| 399 |
|
| 400 |
Returns:
|
| 401 |
幻觉检测器实例
|
|
@@ -404,8 +404,6 @@ def initialize_hallucination_detector(method: str = "lightweight") -> object:
|
|
| 404 |
return VectaraHallucinationDetector()
|
| 405 |
elif method == "nli":
|
| 406 |
return NLIHallucinationDetector()
|
| 407 |
-
elif method == "lightweight":
|
| 408 |
-
return LightweightHallucinationDetector()
|
| 409 |
elif method == "hybrid":
|
| 410 |
return HybridHallucinationDetector(use_vectara=False, use_nli=True) # 禁用Vectara,使用NLI
|
| 411 |
else:
|
|
|
|
| 390 |
return "no" if result['has_hallucination'] else "yes"
|
| 391 |
|
| 392 |
|
| 393 |
+
def initialize_hallucination_detector(method: str = "nli") -> object:
|
| 394 |
"""
|
| 395 |
初始化幻觉检测器
|
| 396 |
|
| 397 |
Args:
|
| 398 |
+
method: 'vectara', 'nli', 或 'hybrid' (推荐)
|
| 399 |
|
| 400 |
Returns:
|
| 401 |
幻觉检测器实例
|
|
|
|
| 404 |
return VectaraHallucinationDetector()
|
| 405 |
elif method == "nli":
|
| 406 |
return NLIHallucinationDetector()
|
|
|
|
|
|
|
| 407 |
elif method == "hybrid":
|
| 408 |
return HybridHallucinationDetector(use_vectara=False, use_nli=True) # 禁用Vectara,使用NLI
|
| 409 |
else:
|