| import re | |
| def evaluate_instruction_drift(response: str): | |
| violations = { | |
| "conciseness_violation": len(response.split()) > 120, | |
| "speculation_violation": bool( | |
| re.search(r"\b(might|could|possibly|likely)\b", response.lower()) | |
| ), | |
| "uncertainty_missing": "uncertain" not in response.lower() | |
| } | |
| drift_score = round( | |
| sum(violations.values()) / len(violations), | |
| 2 | |
| ) | |
| return violations, drift_score | |