Mukul Rayana commited on
Commit ·
2668471
1
Parent(s): 7fc5654
fix: MistralJudge JSON extraction for DeepEval faithfulness, commit Wilcoxon results (Day 15)
Browse files- eval/run_ragas.py +18 -1
- eval/wilcoxon_results.json +112 -0
eval/run_ragas.py
CHANGED
|
@@ -52,7 +52,24 @@ class MistralJudge(DeepEvalBaseLLM):
|
|
| 52 |
temperature=0.0,
|
| 53 |
stop=["[INST]"],
|
| 54 |
)
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
async def a_generate(self, prompt: str) -> str:
|
| 58 |
# DeepEval calls a_generate when async_mode=True.
|
|
|
|
| 52 |
temperature=0.0,
|
| 53 |
stop=["[INST]"],
|
| 54 |
)
|
| 55 |
+
text = out["choices"][0]["text"].strip()
|
| 56 |
+
# Extract valid JSON from response — Mistral occasionally appends
|
| 57 |
+
# commentary after the JSON block which causes DeepEval to fail.
|
| 58 |
+
# Find the outermost JSON object or array and return only that.
|
| 59 |
+
import re
|
| 60 |
+
# Try to find JSON array first (claim lists), then object (verdicts)
|
| 61 |
+
for pattern in (r"\[.*?\]", r"\{.*?\}"):
|
| 62 |
+
match = re.search(pattern, text, re.DOTALL)
|
| 63 |
+
if match:
|
| 64 |
+
candidate = match.group(0)
|
| 65 |
+
try:
|
| 66 |
+
import json as _json
|
| 67 |
+
_json.loads(candidate) # validate
|
| 68 |
+
return candidate
|
| 69 |
+
except Exception:
|
| 70 |
+
continue
|
| 71 |
+
# No valid JSON found — return as-is and let DeepEval handle it
|
| 72 |
+
return text
|
| 73 |
|
| 74 |
async def a_generate(self, prompt: str) -> str:
|
| 75 |
# DeepEval calls a_generate when async_mode=True.
|
eval/wilcoxon_results.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
| 107 |
+
],
|
| 108 |
+
"wilcoxon_statistic": 1044.0,
|
| 109 |
+
"p_value": 3.6189149358699976e-08,
|
| 110 |
+
"significant": true,
|
| 111 |
+
"n": 50
|
| 112 |
+
}
|