File size: 3,868 Bytes
8c10cf2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | # SQLAssistant-H_A2A Evaluation Scripts
This directory contains evaluation scripts for the SQLAssistant-H_A2A project, which analyzes the execution trajectories and performance metrics of different AI models.
## Files
### Configuration
- `reference_trajectory.yaml` - Reference trajectory configuration defining the expected execution path for the SQLAssistant workflow
### Evaluation Scripts
- `evaluate_trajectory-Filter_Tools-mix.py` - Main trajectory evaluation script that computes 6 trajectory metrics
- `evaluate_success.py` - Success rate analysis based on required tool execution
- `evaluate_scores.py` - Score statistics collection from execution logs
- `analyze_retry_patterns.py` - RETRY pattern analysis including business retries and orchestrator retries
## Trajectory Metrics
The evaluation framework computes the following 6 metrics:
1. **Exact Match** - Predicted trajectory must exactly match the reference trajectory
2. **In-Order Match** - Reference trajectory must be a subsequence of predicted trajectory
3. **Any-Order Match** - Predicted trajectory must contain all necessary actions (order-agnostic)
4. **Precision** - Ratio of correct actions in predicted trajectory
5. **Recall** - Ratio of reference actions covered by predicted trajectory
6. **Single-Tool Use** - Usage rate of specific tools
Additional diversity metrics:
- **Unique Path Ratio** - Number of unique trajectories / total samples
- **Path Entropy** - Shannon entropy of trajectory distribution
## Usage
### Trajectory Evaluation
```bash
python3 evaluate_trajectory-Filter_Tools-mix.py --config reference_trajectory.yaml
```
Options:
- `--config` - Path to reference trajectory configuration file (YAML format)
- `--base-dir` - RESULTS directory path (defaults to two levels up from script location)
- `--output` - Output CSV file path
- `--diagnose-failures` - Diagnose any_order_match failure reasons and generate report
### Success Rate Analysis
```bash
python3 evaluate_success.py
```
Success criterion: Whether the `get_database_schema` tool was executed (required for understanding database structure).
### Score Statistics
```bash
python3 evaluate_scores.py
```
Collects and analyzes scores from execution logs.
### Retry Pattern Analysis
```bash
python3 analyze_retry_patterns.py
```
Analyzes two types of retries:
1. **Orchestrator RETRY** - Framework-level retries (e.g., `[SPAN] crew_execution (retry N)`)
2. **BUSINESS-RETRY** - Business logic retries (e.g., `[SPAN] generate_sql (business_retry N)`)
## Models Evaluated
- GPT-5
- GPT-4o-mini
- DeepSeek-V3-1
- DeepSeek-R1
- Gemini-2.5-flash
- Gemini-2.5-flash-nothinking
- Qwen3-235b
## Project Structure
The SQLAssistant-H_A2A project uses a hybrid architecture combining:
- **CrewAI** for SQL generation stage
- **LangGraph** for compliance checking stage
- **AutoGen** for result interpretation stage
### Workflow Stages
1. **Generate SQL** - CrewAI-based SQL generation with two agents:
- Expert SQL Query Generator
- Senior SQL Code Reviewer
2. **Check Compliance** - LangGraph orchestration for compliance validation
3. **Interpret Results** - AutoGen-based result interpretation and SQL execution
## Output Files
- `evaluation_results.csv` - Trajectory evaluation results for all models
- `success_rate.csv` - Success rate summary
- `success_detailed_results.json` - Detailed success analysis
- `score_summary.csv` - Score statistics summary
- `score_analysis.json` - Detailed score analysis
- `retry_summary.csv` - Retry pattern summary
- `retry_analysis.json` - Detailed retry analysis
- `error_by_agent.csv` - Error statistics by agent
- `business_retry_chapters.csv` - Business retry location statistics
- `any_order_match_failures.csv` - Failure diagnosis (if enabled)
## Requirements
- Python 3.x
- pandas
- PyYAML
- pathlib
- collections
- json
- csv
- re
- math
|