Update evaluator_module.py (#3)
Browse files- Update evaluator_module.py (2095467f32da5e3c757a125109d48dda924c111c)
Co-authored-by: Manay Porwal <manayporwal07@users.noreply.huggingface.co>
- evaluator_module.py +9 -9
evaluator_module.py
CHANGED
|
@@ -47,10 +47,10 @@ class AetherScoreEvaluator:
|
|
| 47 |
query = (
|
| 48 |
f"Prompt: {prompt}\n"
|
| 49 |
f"Response: {response}\n\n"
|
| 50 |
-
"
|
| 51 |
-
"hallucination_score
|
| 52 |
-
"assumption_control
|
| 53 |
-
"Then
|
| 54 |
)
|
| 55 |
|
| 56 |
# Calling our LLM
|
|
@@ -68,13 +68,13 @@ class AetherScoreEvaluator:
|
|
| 68 |
assumption_score = 0.0
|
| 69 |
explanation = output
|
| 70 |
|
| 71 |
-
match_h = re.search(r"hallucination[_ ]?score[: ]?([
|
| 72 |
-
match_a = re.search(r"assumption[_ ]?control[: ]?([
|
| 73 |
-
|
| 74 |
if match_h:
|
| 75 |
-
halluc_score = float(match_h.group(
|
| 76 |
if match_a:
|
| 77 |
-
assumption_score = float(match_a.group(
|
| 78 |
|
| 79 |
return {
|
| 80 |
"hallucination_score": (halluc_score, explanation),
|
|
|
|
| 47 |
query = (
|
| 48 |
f"Prompt: {prompt}\n"
|
| 49 |
f"Response: {response}\n\n"
|
| 50 |
+
"First, output ONLY two scores on separate lines:\n"
|
| 51 |
+
"hallucination_score=<float between 0 and 1>\n"
|
| 52 |
+
"assumption_control=<float between 0 and 1>\n"
|
| 53 |
+
"Then, after that, give a short explanation (1–2 sentences)."
|
| 54 |
)
|
| 55 |
|
| 56 |
# Calling our LLM
|
|
|
|
| 68 |
assumption_score = 0.0
|
| 69 |
explanation = output
|
| 70 |
|
| 71 |
+
match_h = re.search(r"hallucination[_ ]?(score)?[:= ]?\s*([0-1](?:\.\d+)?)", output, re.I)
|
| 72 |
+
match_a = re.search(r"assumption[_ ]?(control|score)?[:= ]?\s*([0-1](?:\.\d+)?)", output, re.I)
|
| 73 |
+
|
| 74 |
if match_h:
|
| 75 |
+
halluc_score = float(match_h.group(2))
|
| 76 |
if match_a:
|
| 77 |
+
assumption_score = float(match_a.group(2))
|
| 78 |
|
| 79 |
return {
|
| 80 |
"hallucination_score": (halluc_score, explanation),
|