AditiShashiKhare commited on
Commit
6eba580
·
verified ·
1 Parent(s): 82bb1ef

Create drift_env.py

Browse files
Files changed (1) hide show
  1. drift_env.py +17 -0
drift_env.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ def evaluate_instruction_drift(response: str):
4
+ violations = {
5
+ "conciseness_violation": len(response.split()) > 120,
6
+ "speculation_violation": bool(
7
+ re.search(r"\b(might|could|possibly|likely)\b", response.lower())
8
+ ),
9
+ "uncertainty_missing": "uncertain" not in response.lower()
10
+ }
11
+
12
+ drift_score = round(
13
+ sum(violations.values()) / len(violations),
14
+ 2
15
+ )
16
+
17
+ return violations, drift_score