qualia_core_db/inference/conditioning_eval/
scoring.rs1#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]
4pub struct TaskScore {
5 pub accuracy: f32,
6 pub citation_fidelity: f32,
7 pub constraint_satisfaction: f32,
8}
9
10impl TaskScore {
11 pub fn composite_score(&self) -> f32 {
13 0.5 * self.accuracy + 0.3 * self.citation_fidelity + 0.2 * self.constraint_satisfaction
14 }
15}
16
17pub fn evaluate_task_output(
19 actual: &str,
20 expected: &str,
21 citations_present: bool,
22 constraints_satisfied: bool,
23) -> TaskScore {
24 let accuracy = if actual.trim() == expected.trim() {
25 1.0
26 } else if actual.contains(expected) {
27 0.7
28 } else {
29 0.0
30 };
31
32 let citation_fidelity = if citations_present { 1.0 } else { 0.0 };
33 let constraint_satisfaction = if constraints_satisfied { 1.0 } else { 0.0 };
34
35 TaskScore {
36 accuracy,
37 citation_fidelity,
38 constraint_satisfaction,
39 }
40}