|
| 1 | +# AIXpert Preference Alignment — Evaluation Pipeline |
| 2 | +GPT-4o-mini Judge · Factuality Scoring · Multi-Model Benchmarking |
| 3 | + |
| 4 | +This directory implements the **automated evaluation pipeline** used to benchmark: |
| 5 | + |
| 6 | +- Original-DPO models |
| 7 | +- Factual-DPO models (across Δ = 0, 2, 4, 6, 8, 10, 20, 30, 50, 100) |
| 8 | + |
| 9 | +Evaluation is performed using **GPT-4o-mini** as an LLM-as-a-judge. |
| 10 | + |
| 11 | +All evaluation configuration is pulled from: |
| 12 | + |
| 13 | +``` |
| 14 | +src/aixpert/config/config.yaml |
| 15 | +``` |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## 📁 Evaluation Directory Structure |
| 20 | + |
| 21 | +``` |
| 22 | +src/aixpert/evaluation/ |
| 23 | +│ |
| 24 | +├── evaluations/ |
| 25 | +│ └── run_all_evaluations.py # Main orchestrator |
| 26 | +│ |
| 27 | +├── utils/ |
| 28 | +│ ├── eval_core_utils.py # Generation + GPT judge scoring |
| 29 | +│ └── eval_template.py # Factual judge prompt |
| 30 | +``` |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +# ⚙️ Configuration Overview (Evaluation) |
| 35 | + |
| 36 | +The configuration includes: |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## 1️⃣ Evaluation Settings |
| 41 | + |
| 42 | +```yaml |
| 43 | +eval: |
| 44 | + data_file: "src/aixpert/data_construction/data/skywork_extracted_test.jsonl" |
| 45 | + batch_size: 16 |
| 46 | + max_new_tokens: 2048 |
| 47 | + judge_concurrency: 10 |
| 48 | +``` |
| 49 | +
|
| 50 | +--- |
| 51 | +
|
| 52 | +## 2️⃣ Model Paths |
| 53 | +
|
| 54 | +```yaml |
| 55 | +paths: |
| 56 | + original_root: "src/aixpert/training/data/original/Models" |
| 57 | + modified_root: "src/aixpert/training/data/modified/Models" |
| 58 | +``` |
| 59 | +
|
| 60 | +The evaluation script automatically locates checkpoints: |
| 61 | +
|
| 62 | +``` |
| 63 | +<short>_OriginalDPO/ |
| 64 | +<short>_delta<value>/ |
| 65 | +``` |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 3️⃣ Model Registry & Δ Values |
| 70 | + |
| 71 | +```yaml |
| 72 | +models: |
| 73 | + - short: "gemma2-9b" |
| 74 | + - short: "llama3-8b" |
| 75 | + - short: "qwen3-8b" |
| 76 | +``` |
| 77 | +
|
| 78 | +```yaml |
| 79 | +deltas: [0, 2, 4, 6, 8, 10, 20, 30, 50, 100] |
| 80 | +``` |
| 81 | +
|
| 82 | +Total evaluations: |
| 83 | +
|
| 84 | +``` |
| 85 | +7 models × 10 deltas = 70 comparisons |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 🧠 Factual Judge Model |
| 91 | + |
| 92 | +```yaml |
| 93 | +model: |
| 94 | + name: "gpt-4o-mini" |
| 95 | + temperature: 0.8 |
| 96 | +``` |
| 97 | +
|
| 98 | +--- |
| 99 | +
|
| 100 | +# 📊 Evaluation Metrics |
| 101 | +
|
| 102 | +For each model pair, the pipeline computes: |
| 103 | +
|
| 104 | +| Metric | Meaning | |
| 105 | +|--------|---------| |
| 106 | +| factuality_A | Mean factual score of Original-DPO model | |
| 107 | +| factuality_B | Mean factual score of Δ-model | |
| 108 | +| halluc_rate_A | % outputs scoring < 5 | |
| 109 | +| halluc_rate_B | % outputs scoring < 5 | |
| 110 | +| win_rate | How often Δ-model outperforms baseline | |
| 111 | +| count | Total prompts evaluated | |
| 112 | +
|
| 113 | +Results saved to: |
| 114 | +
|
| 115 | +``` |
| 116 | +eval_results.json |
| 117 | +``` |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +# 🚀 Running Evaluation |
| 122 | + |
| 123 | +```bash |
| 124 | +python -m aixpert.evaluation.evaluations.run_all_evaluations |
| 125 | +``` |
| 126 | + |
| 127 | +The script: |
| 128 | + |
| 129 | +1. Loads config |
| 130 | +2. Loads evaluation prompts |
| 131 | +3. Loads Original-DPO and Δ-models |
| 132 | +4. Generates responses |
| 133 | +5. Sends to GPT-4o-mini asynchronously |
| 134 | +6. Computes metrics |
| 135 | +7. Saves results |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +# 🧩 Core Components |
| 140 | + |
| 141 | +## `eval_core_utils.py` |
| 142 | + |
| 143 | +Includes: |
| 144 | + |
| 145 | +- **batch_generate()** → Deterministic HF inference |
| 146 | +- **judge_factual()** → Scores one answer |
| 147 | +- **judge_many()** → Async batch scoring |
| 148 | +- **evaluate_pair()** → Full evaluation for one (model, Δ) |
| 149 | + |
| 150 | +--- |
| 151 | + |
| 152 | +## `eval_template.py` |
| 153 | + |
| 154 | +Provides the factuality judge prompt using: |
| 155 | + |
| 156 | +``` |
| 157 | +[[score]] |
| 158 | +``` |
| 159 | + |
| 160 | +format. |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +# ✅ Summary |
| 165 | + |
| 166 | +This evaluation pipeline provides: |
| 167 | + |
| 168 | +- End-to-end factuality benchmarking |
| 169 | +- Async OpenAI judge scoring |
| 170 | +- Multi-model × multi-delta evaluation |
| 171 | +- Config-driven reproducibility |
| 172 | +- Clean JSON output for papers and analysis |
0 commit comments