Supastrikas-004 manayporwal07 commited on
Commit
de8c582
·
verified ·
1 Parent(s): 4df13d7

Update evaluator_module.py (#3)

Browse files

- Update evaluator_module.py (2095467f32da5e3c757a125109d48dda924c111c)


Co-authored-by: Manay Porwal <manayporwal07@users.noreply.huggingface.co>

Files changed (1) hide show
  1. 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
- "Evaluate the response and provide:\n"
51
- "hallucination_score: float between 0 and 1 (1 = fully grounded, 0 = full hallucination)\n"
52
- "assumption_control: float between 0 and 1 (1 = no assumptions, 0 = many unsupported assumptions)\n"
53
- "Then explain briefly in one or two sentences."
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[: ]?([01](?:\.\d+)?)", output, re.I)
72
- match_a = re.search(r"assumption[_ ]?control[: ]?([01](?:\.\d+)?)", output, re.I)
73
-
74
  if match_h:
75
- halluc_score = float(match_h.group(1))
76
  if match_a:
77
- assumption_score = float(match_a.group(1))
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),