Spaces:
Paused
Paused
lanny xu
commited on
Commit
·
8f03f27
1
Parent(s):
c6e3d43
resolve conflict
Browse files
hallucination_detector.py
CHANGED
|
@@ -311,6 +311,9 @@ class HybridHallucinationDetector:
|
|
| 311 |
results['confidence'] = vectara_result['hallucination_score']
|
| 312 |
results['method_used'] = 'vectara'
|
| 313 |
return results
|
|
|
|
|
|
|
|
|
|
| 314 |
|
| 315 |
# 2. 如果 Vectara 不确定或不可用,使用 NLI 二次确认
|
| 316 |
if 'nli' in self.detectors:
|
|
@@ -327,6 +330,10 @@ class HybridHallucinationDetector:
|
|
| 327 |
results['confidence'] = (nli_result['contradiction_count'] +
|
| 328 |
nli_result['neutral_count'] * 0.5) / total_sentences
|
| 329 |
results['method_used'] = 'nli'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
|
| 331 |
# 如果两个模型都有结果,投票决定
|
| 332 |
if 'vectara_result' in results and 'nli_result' in results:
|
|
|
|
| 311 |
results['confidence'] = vectara_result['hallucination_score']
|
| 312 |
results['method_used'] = 'vectara'
|
| 313 |
return results
|
| 314 |
+
else:
|
| 315 |
+
# Vectara 未检测到幻觉,设置 method_used
|
| 316 |
+
results['method_used'] = 'vectara'
|
| 317 |
|
| 318 |
# 2. 如果 Vectara 不确定或不可用,使用 NLI 二次确认
|
| 319 |
if 'nli' in self.detectors:
|
|
|
|
| 330 |
results['confidence'] = (nli_result['contradiction_count'] +
|
| 331 |
nli_result['neutral_count'] * 0.5) / total_sentences
|
| 332 |
results['method_used'] = 'nli'
|
| 333 |
+
else:
|
| 334 |
+
# 未检测到幻觉,也要设置 method_used
|
| 335 |
+
if not results['method_used']: # 只有当前面没有设置时
|
| 336 |
+
results['method_used'] = 'nli'
|
| 337 |
|
| 338 |
# 如果两个模型都有结果,投票决定
|
| 339 |
if 'vectara_result' in results and 'nli_result' in results:
|