@@ -34,9 +34,16 @@ def format_precision_key(precision_value: float) -> str:
3434 return f"{ rounded :.4f} "
3535
3636
37- def analyze_precision_performance (search_results : Dict [str , Any ]) -> Dict [str , Dict [str , Any ]]:
38- """Analyze search results to find best RPS at each actual precision level achieved."""
37+ def analyze_precision_performance (search_results : Dict [str , Any ]) -> tuple [Dict [str , Dict [str , Any ]], Dict [str , Dict [str , float ]]]:
38+ """Analyze search results to find best RPS at each actual precision level achieved.
39+
40+ Returns:
41+ tuple: (precision_dict, precision_summary_dict)
42+ - precision_dict: Full precision analysis with config details
43+ - precision_summary_dict: Simplified summary with just QPS, P50, P95
44+ """
3945 precision_dict = {}
46+ precision_summary_dict = {}
4047
4148 # First, collect all actual precision levels achieved by experiments and format them
4249 precision_mapping = {} # Maps formatted precision to actual precision
@@ -53,6 +60,8 @@ def analyze_precision_performance(search_results: Dict[str, Any]) -> Dict[str, D
5360 best_rps = 0
5461 best_config = None
5562 best_experiment_id = None
63+ best_p50_time = 0
64+ best_p95_time = 0
5665
5766 for experiment_id , experiment_data in search_results .items ():
5867 mean_precision = experiment_data ["results" ]["mean_precisions" ]
@@ -66,16 +75,26 @@ def analyze_precision_performance(search_results: Dict[str, Any]) -> Dict[str, D
6675 "search_params" : experiment_data ["params" ]["search_params" ]
6776 }
6877 best_experiment_id = experiment_id
78+ best_p50_time = experiment_data ["results" ]["p50_time" ]
79+ best_p95_time = experiment_data ["results" ]["p95_time" ]
6980
7081 # Add to precision dict with the formatted precision as key
7182 if best_config is not None :
83+ # Full precision analysis (existing format)
7284 precision_dict [formatted_precision ] = {
7385 "rps" : best_rps ,
7486 "config" : best_config ,
7587 "experiment_id" : best_experiment_id
7688 }
7789
78- return precision_dict
90+ # Simplified precision summary
91+ precision_summary_dict [formatted_precision ] = {
92+ "qps" : round (best_rps , 1 ),
93+ "p50" : round (best_p50_time * 1000 , 3 ), # Convert to ms
94+ "p95" : round (best_p95_time * 1000 , 3 ) # Convert to ms
95+ }
96+
97+ return precision_dict , precision_summary_dict
7998
8099warnings .filterwarnings ("ignore" , category = DeprecationWarning )
81100
@@ -285,10 +304,12 @@ def run_experiment(
285304
286305 # Add precision analysis if search results exist
287306 if results ["search" ]:
288- precision_analysis = analyze_precision_performance (results ["search" ])
307+ precision_analysis , precision_summary = analyze_precision_performance (results ["search" ])
289308 if precision_analysis : # Only add if we have precision data
290309 results ["precision" ] = precision_analysis
310+ results ["precision_summary" ] = precision_summary
291311 print (f"Added precision analysis with { len (precision_analysis )} precision thresholds" )
312+ print (f"Added precision summary with { len (precision_summary )} precision levels" )
292313
293314 summary_file = f"{ self .name } -{ dataset .config .name } -summary.json"
294315 summary_path = RESULTS_DIR / summary_file
0 commit comments