Datasets:
Keep generated responses when an optional judge request fails
Browse files- quick_eval.py +5 -1
quick_eval.py
CHANGED
|
@@ -54,7 +54,11 @@ def main():
|
|
| 54 |
record={'id':row['id'],'family_id':row['family_id'],'replicate':rep,'status':'OK','generation':result}
|
| 55 |
if a.judge_model:
|
| 56 |
data={'id':row['id'],'prompt':row['prompt'],'response':result['text']}
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
try:
|
| 59 |
label=json.loads(j['text']);choice=label['choice'];evidence=label.get('evidence','')
|
| 60 |
if choice not in {'SUBJECT','ALTERNATIVE','UNKNOWN'}:raise ValueError('Invalid choice')
|
|
|
|
| 54 |
record={'id':row['id'],'family_id':row['family_id'],'replicate':rep,'status':'OK','generation':result}
|
| 55 |
if a.judge_model:
|
| 56 |
data={'id':row['id'],'prompt':row['prompt'],'response':result['text']}
|
| 57 |
+
try:
|
| 58 |
+
j=chat(a.judge_base_url or a.base_url,judge_key,a.judge_model,[{'role':'system','content':RULE},{'role':'user','content':json.dumps(data)}],jp)
|
| 59 |
+
except Exception as e:
|
| 60 |
+
record.update({'status':'JUDGE_ERROR','error_type':type(e).__name__})
|
| 61 |
+
return record # Preserve the successful generation even when its judge fails.
|
| 62 |
try:
|
| 63 |
label=json.loads(j['text']);choice=label['choice'];evidence=label.get('evidence','')
|
| 64 |
if choice not in {'SUBJECT','ALTERNATIVE','UNKNOWN'}:raise ValueError('Invalid choice')
|