Spaces:
Sleeping
Sleeping
YanBoChen
commited on
Commit
Β·
2f35ee2
1
Parent(s):
3edd46d
Add RAG vs Direct Latency Comparison Chart Generator for performance analysis
Browse files
evaluation/rag_vs_direct_latency_chart_generator.py
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
OnCall.ai System - RAG vs Direct Latency Comparison Chart Generator
|
| 4 |
+
==================================================================
|
| 5 |
+
|
| 6 |
+
Compares RAG and Direct LLM system latency performance.
|
| 7 |
+
Reads statistics from latency_statistics_*.json and direct_llm_statistics_*.json
|
| 8 |
+
|
| 9 |
+
No LLM calls - pure data visualization.
|
| 10 |
+
|
| 11 |
+
Author: YanBo Chen
|
| 12 |
+
Date: 2025-08-05
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
import json
|
| 16 |
+
import os
|
| 17 |
+
import sys
|
| 18 |
+
from typing import Dict, List, Any, Tuple
|
| 19 |
+
from datetime import datetime
|
| 20 |
+
from pathlib import Path
|
| 21 |
+
import glob
|
| 22 |
+
|
| 23 |
+
# Visualization imports
|
| 24 |
+
import matplotlib.pyplot as plt
|
| 25 |
+
import seaborn as sns
|
| 26 |
+
import pandas as pd
|
| 27 |
+
import numpy as np
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class RAGvsDirectLatencyChartGenerator:
|
| 31 |
+
"""Generate RAG vs Direct latency comparison charts"""
|
| 32 |
+
|
| 33 |
+
def __init__(self):
|
| 34 |
+
"""Initialize chart generator"""
|
| 35 |
+
print("π Initializing RAG vs Direct Latency Chart Generator...")
|
| 36 |
+
|
| 37 |
+
# Set up professional chart style
|
| 38 |
+
plt.style.use('default')
|
| 39 |
+
sns.set_palette("husl")
|
| 40 |
+
|
| 41 |
+
# Define system colors
|
| 42 |
+
self.system_colors = {
|
| 43 |
+
'rag': '#1f77b4', # Blue
|
| 44 |
+
'direct': '#ff7f0e' # Orange
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
print("β
Chart Generator ready with professional medical styling")
|
| 48 |
+
|
| 49 |
+
def find_latest_statistics_files(self) -> Tuple[str, str]:
|
| 50 |
+
"""
|
| 51 |
+
Find the most recent RAG and Direct statistics files
|
| 52 |
+
|
| 53 |
+
Returns:
|
| 54 |
+
Tuple of (rag_file_path, direct_file_path)
|
| 55 |
+
"""
|
| 56 |
+
results_dir = Path(__file__).parent / "results"
|
| 57 |
+
|
| 58 |
+
# Find RAG statistics file
|
| 59 |
+
rag_pattern = str(results_dir / "latency_statistics_*.json")
|
| 60 |
+
rag_files = glob.glob(rag_pattern)
|
| 61 |
+
|
| 62 |
+
if not rag_files:
|
| 63 |
+
raise FileNotFoundError(f"No RAG latency statistics files found with pattern: {rag_pattern}")
|
| 64 |
+
|
| 65 |
+
latest_rag_file = max(rag_files, key=os.path.getmtime)
|
| 66 |
+
|
| 67 |
+
# Find Direct statistics file
|
| 68 |
+
direct_pattern = str(results_dir / "direct_llm_statistics_*.json")
|
| 69 |
+
direct_files = glob.glob(direct_pattern)
|
| 70 |
+
|
| 71 |
+
if not direct_files:
|
| 72 |
+
raise FileNotFoundError(f"No Direct LLM statistics files found with pattern: {direct_pattern}")
|
| 73 |
+
|
| 74 |
+
latest_direct_file = max(direct_files, key=os.path.getmtime)
|
| 75 |
+
|
| 76 |
+
print(f"π Found RAG statistics: {latest_rag_file}")
|
| 77 |
+
print(f"π Found Direct statistics: {latest_direct_file}")
|
| 78 |
+
|
| 79 |
+
return latest_rag_file, latest_direct_file
|
| 80 |
+
|
| 81 |
+
def load_statistics(self, rag_file: str, direct_file: str) -> Tuple[Dict, Dict]:
|
| 82 |
+
"""
|
| 83 |
+
Load statistics from both files
|
| 84 |
+
|
| 85 |
+
Args:
|
| 86 |
+
rag_file: Path to RAG statistics file
|
| 87 |
+
direct_file: Path to Direct statistics file
|
| 88 |
+
|
| 89 |
+
Returns:
|
| 90 |
+
Tuple of (rag_stats, direct_stats)
|
| 91 |
+
"""
|
| 92 |
+
print(f"π Loading RAG statistics from: {rag_file}")
|
| 93 |
+
with open(rag_file, 'r', encoding='utf-8') as f:
|
| 94 |
+
rag_stats = json.load(f)
|
| 95 |
+
|
| 96 |
+
print(f"π Loading Direct statistics from: {direct_file}")
|
| 97 |
+
with open(direct_file, 'r', encoding='utf-8') as f:
|
| 98 |
+
direct_stats = json.load(f)
|
| 99 |
+
|
| 100 |
+
return rag_stats, direct_stats
|
| 101 |
+
|
| 102 |
+
def generate_comparison_charts(self, rag_stats: Dict, direct_stats: Dict) -> str:
|
| 103 |
+
"""
|
| 104 |
+
Generate comprehensive RAG vs Direct latency comparison charts
|
| 105 |
+
|
| 106 |
+
Creates 4-panel comparison:
|
| 107 |
+
1. Category-wise latency comparison
|
| 108 |
+
2. Overall performance comparison
|
| 109 |
+
3. Target compliance comparison
|
| 110 |
+
4. Success rate comparison
|
| 111 |
+
"""
|
| 112 |
+
try:
|
| 113 |
+
# Create figure with subplots
|
| 114 |
+
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
|
| 115 |
+
fig.suptitle('RAG vs Direct LLM - Latency Performance Comparison',
|
| 116 |
+
fontsize=16, fontweight='bold')
|
| 117 |
+
|
| 118 |
+
# Chart 1: Category-wise Latency Comparison
|
| 119 |
+
ax1 = axes[0, 0]
|
| 120 |
+
categories = ['diagnosis', 'treatment', 'mixed']
|
| 121 |
+
rag_latencies = []
|
| 122 |
+
direct_latencies = []
|
| 123 |
+
|
| 124 |
+
for category in categories:
|
| 125 |
+
rag_cat = rag_stats['category_results'].get(category, {})
|
| 126 |
+
direct_cat = direct_stats['category_results'].get(category, {})
|
| 127 |
+
|
| 128 |
+
rag_latencies.append(rag_cat.get('average_latency', 0))
|
| 129 |
+
direct_latencies.append(direct_cat.get('average_latency', 0))
|
| 130 |
+
|
| 131 |
+
x = np.arange(len(categories))
|
| 132 |
+
width = 0.35
|
| 133 |
+
|
| 134 |
+
bars1 = ax1.bar(x - width/2, rag_latencies, width, label='RAG',
|
| 135 |
+
color=self.system_colors['rag'], alpha=0.8)
|
| 136 |
+
bars2 = ax1.bar(x + width/2, direct_latencies, width, label='Direct LLM',
|
| 137 |
+
color=self.system_colors['direct'], alpha=0.8)
|
| 138 |
+
|
| 139 |
+
ax1.set_title('Latency by Category', fontweight='bold')
|
| 140 |
+
ax1.set_ylabel('Average Latency (seconds)')
|
| 141 |
+
ax1.set_xlabel('Query Category')
|
| 142 |
+
ax1.set_xticks(x)
|
| 143 |
+
ax1.set_xticklabels([cat.capitalize() for cat in categories])
|
| 144 |
+
ax1.legend()
|
| 145 |
+
ax1.grid(True, alpha=0.3)
|
| 146 |
+
|
| 147 |
+
# Add target line
|
| 148 |
+
ax1.axhline(y=60.0, color='red', linestyle='--', alpha=0.7, label='60s Target')
|
| 149 |
+
ax1.legend()
|
| 150 |
+
|
| 151 |
+
# Add value labels on bars
|
| 152 |
+
for bars in [bars1, bars2]:
|
| 153 |
+
for bar in bars:
|
| 154 |
+
height = bar.get_height()
|
| 155 |
+
if height > 0:
|
| 156 |
+
ax1.text(bar.get_x() + bar.get_width()/2., height + 1,
|
| 157 |
+
f'{height:.1f}s', ha='center', va='bottom', fontsize=9)
|
| 158 |
+
|
| 159 |
+
# Chart 2: Overall Performance Comparison
|
| 160 |
+
ax2 = axes[0, 1]
|
| 161 |
+
|
| 162 |
+
systems = ['RAG', 'Direct LLM']
|
| 163 |
+
overall_latencies = [
|
| 164 |
+
rag_stats['overall_results']['average_latency'],
|
| 165 |
+
direct_stats['overall_results']['average_latency']
|
| 166 |
+
]
|
| 167 |
+
|
| 168 |
+
bars = ax2.bar(systems, overall_latencies,
|
| 169 |
+
color=[self.system_colors['rag'], self.system_colors['direct']],
|
| 170 |
+
alpha=0.8)
|
| 171 |
+
|
| 172 |
+
ax2.set_title('Overall Average Latency', fontweight='bold')
|
| 173 |
+
ax2.set_ylabel('Average Latency (seconds)')
|
| 174 |
+
ax2.grid(True, alpha=0.3)
|
| 175 |
+
|
| 176 |
+
# Add target line
|
| 177 |
+
ax2.axhline(y=60.0, color='red', linestyle='--', alpha=0.7, label='60s Target')
|
| 178 |
+
ax2.legend()
|
| 179 |
+
|
| 180 |
+
# Add value labels
|
| 181 |
+
for bar, value in zip(bars, overall_latencies):
|
| 182 |
+
height = bar.get_height()
|
| 183 |
+
ax2.text(bar.get_x() + bar.get_width()/2., height + 1,
|
| 184 |
+
f'{value:.1f}s', ha='center', va='bottom', fontweight='bold')
|
| 185 |
+
|
| 186 |
+
# Chart 3: Target Compliance Comparison
|
| 187 |
+
ax3 = axes[1, 0]
|
| 188 |
+
|
| 189 |
+
rag_compliance = rag_stats['overall_results']['target_compliance'] * 100
|
| 190 |
+
direct_compliance = direct_stats['overall_results']['target_compliance'] * 100
|
| 191 |
+
|
| 192 |
+
compliance_data = [rag_compliance, direct_compliance]
|
| 193 |
+
|
| 194 |
+
bars = ax3.bar(systems, compliance_data,
|
| 195 |
+
color=[self.system_colors['rag'], self.system_colors['direct']],
|
| 196 |
+
alpha=0.8)
|
| 197 |
+
|
| 198 |
+
ax3.set_title('60s Target Compliance Rate', fontweight='bold')
|
| 199 |
+
ax3.set_ylabel('Compliance Rate (%)')
|
| 200 |
+
ax3.set_ylim(0, 105)
|
| 201 |
+
ax3.grid(True, alpha=0.3)
|
| 202 |
+
|
| 203 |
+
# Add target line at 100%
|
| 204 |
+
ax3.axhline(y=100.0, color='green', linestyle='--', alpha=0.7, label='100% Target')
|
| 205 |
+
ax3.legend()
|
| 206 |
+
|
| 207 |
+
# Add percentage labels
|
| 208 |
+
for bar, value in zip(bars, compliance_data):
|
| 209 |
+
height = bar.get_height()
|
| 210 |
+
ax3.text(bar.get_x() + bar.get_width()/2., height + 1,
|
| 211 |
+
f'{value:.1f}%', ha='center', va='bottom', fontweight='bold')
|
| 212 |
+
|
| 213 |
+
# Chart 4: Success Rate Comparison
|
| 214 |
+
ax4 = axes[1, 1]
|
| 215 |
+
|
| 216 |
+
rag_success_rate = rag_stats['overall_results']['successful_queries'] / rag_stats['overall_results']['total_queries'] * 100
|
| 217 |
+
direct_success_rate = direct_stats['overall_results']['successful_queries'] / direct_stats['overall_results']['total_queries'] * 100
|
| 218 |
+
|
| 219 |
+
success_data = [rag_success_rate, direct_success_rate]
|
| 220 |
+
|
| 221 |
+
bars = ax4.bar(systems, success_data,
|
| 222 |
+
color=[self.system_colors['rag'], self.system_colors['direct']],
|
| 223 |
+
alpha=0.8)
|
| 224 |
+
|
| 225 |
+
ax4.set_title('Query Success Rate', fontweight='bold')
|
| 226 |
+
ax4.set_ylabel('Success Rate (%)')
|
| 227 |
+
ax4.set_ylim(0, 105)
|
| 228 |
+
ax4.grid(True, alpha=0.3)
|
| 229 |
+
|
| 230 |
+
# Add target line at 100%
|
| 231 |
+
ax4.axhline(y=100.0, color='green', linestyle='--', alpha=0.7, label='100% Target')
|
| 232 |
+
ax4.legend()
|
| 233 |
+
|
| 234 |
+
# Add percentage labels
|
| 235 |
+
for bar, value in zip(bars, success_data):
|
| 236 |
+
height = bar.get_height()
|
| 237 |
+
ax4.text(bar.get_x() + bar.get_width()/2., height + 1,
|
| 238 |
+
f'{value:.1f}%', ha='center', va='bottom', fontweight='bold')
|
| 239 |
+
|
| 240 |
+
# Adjust layout
|
| 241 |
+
plt.tight_layout()
|
| 242 |
+
|
| 243 |
+
# Save chart
|
| 244 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 245 |
+
chart_filename = f"rag_vs_direct_latency_comparison_{timestamp}.png"
|
| 246 |
+
|
| 247 |
+
# Ensure results directory exists
|
| 248 |
+
results_dir = Path(__file__).parent / "results"
|
| 249 |
+
results_dir.mkdir(exist_ok=True)
|
| 250 |
+
chart_path = results_dir / chart_filename
|
| 251 |
+
|
| 252 |
+
plt.savefig(chart_path, dpi=300, bbox_inches='tight',
|
| 253 |
+
facecolor='white', edgecolor='none')
|
| 254 |
+
plt.close()
|
| 255 |
+
|
| 256 |
+
print(f"π RAG vs Direct latency comparison charts saved to: {chart_path}")
|
| 257 |
+
return str(chart_path)
|
| 258 |
+
|
| 259 |
+
except Exception as e:
|
| 260 |
+
print(f"β Chart generation failed: {e}")
|
| 261 |
+
return ""
|
| 262 |
+
|
| 263 |
+
def print_comparison_summary(self, rag_stats: Dict, direct_stats: Dict):
|
| 264 |
+
"""Print formatted comparison summary to console"""
|
| 265 |
+
print(f"\nπ === RAG vs DIRECT LATENCY COMPARISON SUMMARY ===")
|
| 266 |
+
|
| 267 |
+
# Overall comparison
|
| 268 |
+
rag_overall = rag_stats['overall_results']
|
| 269 |
+
direct_overall = direct_stats['overall_results']
|
| 270 |
+
|
| 271 |
+
print(f"\nπ Overall Performance:")
|
| 272 |
+
print(f" RAG System:")
|
| 273 |
+
print(f" β’ Average Latency: {rag_overall['average_latency']:.2f}s")
|
| 274 |
+
print(f" β’ Success Rate: {rag_overall['successful_queries']}/{rag_overall['total_queries']} ({rag_overall['successful_queries']/rag_overall['total_queries']*100:.1f}%)")
|
| 275 |
+
print(f" β’ 60s Target Compliance: {rag_overall['target_compliance']*100:.1f}%")
|
| 276 |
+
|
| 277 |
+
print(f" Direct LLM System:")
|
| 278 |
+
print(f" β’ Average Latency: {direct_overall['average_latency']:.2f}s")
|
| 279 |
+
print(f" β’ Success Rate: {direct_overall['successful_queries']}/{direct_overall['total_queries']} ({direct_overall['success_rate']*100:.1f}%)")
|
| 280 |
+
print(f" β’ 60s Target Compliance: {direct_overall['target_compliance']*100:.1f}%")
|
| 281 |
+
|
| 282 |
+
# Performance winner
|
| 283 |
+
if direct_overall['average_latency'] < rag_overall['average_latency']:
|
| 284 |
+
latency_winner = "Direct LLM"
|
| 285 |
+
latency_improvement = rag_overall['average_latency'] - direct_overall['average_latency']
|
| 286 |
+
else:
|
| 287 |
+
latency_winner = "RAG"
|
| 288 |
+
latency_improvement = direct_overall['average_latency'] - rag_overall['average_latency']
|
| 289 |
+
|
| 290 |
+
print(f"\nπ Performance Winner:")
|
| 291 |
+
print(f" β’ Faster System: {latency_winner}")
|
| 292 |
+
print(f" β’ Performance Improvement: {latency_improvement:.2f}s ({latency_improvement/max(rag_overall['average_latency'], direct_overall['average_latency'])*100:.1f}%)")
|
| 293 |
+
|
| 294 |
+
# Category breakdown
|
| 295 |
+
print(f"\nπ Category Breakdown:")
|
| 296 |
+
categories = ['diagnosis', 'treatment', 'mixed']
|
| 297 |
+
|
| 298 |
+
for category in categories:
|
| 299 |
+
rag_cat = rag_stats['category_results'].get(category, {})
|
| 300 |
+
direct_cat = direct_stats['category_results'].get(category, {})
|
| 301 |
+
|
| 302 |
+
if rag_cat.get('query_count', 0) > 0 and direct_cat.get('query_count', 0) > 0:
|
| 303 |
+
rag_latency = rag_cat.get('average_latency', 0)
|
| 304 |
+
direct_latency = direct_cat.get('average_latency', 0)
|
| 305 |
+
|
| 306 |
+
winner = "Direct" if direct_latency < rag_latency else "RAG"
|
| 307 |
+
difference = abs(rag_latency - direct_latency)
|
| 308 |
+
|
| 309 |
+
print(f" {category.capitalize()}:")
|
| 310 |
+
print(f" β’ RAG: {rag_latency:.2f}s")
|
| 311 |
+
print(f" β’ Direct: {direct_latency:.2f}s")
|
| 312 |
+
print(f" β’ Winner: {winner} (faster by {difference:.2f}s)")
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
# Independent execution interface
|
| 316 |
+
if __name__ == "__main__":
|
| 317 |
+
"""Independent chart generation interface"""
|
| 318 |
+
|
| 319 |
+
print("π OnCall.ai RAG vs Direct Latency Comparison Chart Generator")
|
| 320 |
+
|
| 321 |
+
# Initialize chart generator
|
| 322 |
+
chart_gen = RAGvsDirectLatencyChartGenerator()
|
| 323 |
+
|
| 324 |
+
try:
|
| 325 |
+
# Find latest statistics files
|
| 326 |
+
rag_file, direct_file = chart_gen.find_latest_statistics_files()
|
| 327 |
+
|
| 328 |
+
# Load statistics
|
| 329 |
+
rag_stats, direct_stats = chart_gen.load_statistics(rag_file, direct_file)
|
| 330 |
+
|
| 331 |
+
# Generate comparison charts
|
| 332 |
+
print(f"π Generating RAG vs Direct comparison charts...")
|
| 333 |
+
chart_path = chart_gen.generate_comparison_charts(rag_stats, direct_stats)
|
| 334 |
+
|
| 335 |
+
# Print comparison summary
|
| 336 |
+
chart_gen.print_comparison_summary(rag_stats, direct_stats)
|
| 337 |
+
|
| 338 |
+
print(f"\nβ
RAG vs Direct latency comparison complete!")
|
| 339 |
+
print(f"π Charts saved to: {chart_path}")
|
| 340 |
+
print(f"π‘ Charts optimized for research presentations and publications")
|
| 341 |
+
|
| 342 |
+
except FileNotFoundError as e:
|
| 343 |
+
print(f"β {e}")
|
| 344 |
+
print("π‘ Please ensure both evaluators have been run:")
|
| 345 |
+
print(" python latency_evaluator.py # for RAG statistics")
|
| 346 |
+
print(" python direct_llm_evaluator.py # for Direct statistics")
|
| 347 |
+
except Exception as e:
|
| 348 |
+
print(f"β Chart generation failed: {e}")
|