@@ -1250,6 +1250,11 @@ def _normalize_url(self, url: str) -> str:
12501250
12511251 # return env
12521252
1253+ @staticmethod
1254+ def _pct_to_ratio (value : float ) -> float :
1255+ """Convert a 0-100 percentage to a 0-1 ratio."""
1256+ return round (value / 100 , 4 )
1257+
12531258 def _parse_results (
12541259 self ,
12551260 result : GarakScanResult ,
@@ -1310,8 +1315,8 @@ def _parse_results(
13101315 metrics .append (
13111316 EvaluationResult (
13121317 metric_name = "attack_success_rate" ,
1313- metric_value = overall_asr ,
1314- metric_type = "percentage " ,
1318+ metric_value = self . _pct_to_ratio ( overall_asr ) ,
1319+ metric_type = "ratio " ,
13151320 num_samples = overall_summary .get ("total_attempts" ),
13161321 )
13171322 )
@@ -1350,8 +1355,8 @@ def _parse_results(
13501355 metrics .append (
13511356 EvaluationResult (
13521357 metric_name = f"{ probe_name } _asr" ,
1353- metric_value = attack_success_rate ,
1354- metric_type = "percentage " ,
1358+ metric_value = self . _pct_to_ratio ( attack_success_rate ) ,
1359+ metric_type = "ratio " ,
13551360 num_samples = probe_attempts if not art_intents else None ,
13561361 metadata = probe_metadata ,
13571362 )
@@ -1360,7 +1365,7 @@ def _parse_results(
13601365 overall_score = overall_summary .get ("attack_success_rate" )
13611366 if overall_score is not None :
13621367 try :
1363- overall_score = float (overall_score )
1368+ overall_score = self . _pct_to_ratio ( float (overall_score ) )
13641369 except (TypeError , ValueError ):
13651370 overall_score = None
13661371
@@ -1370,7 +1375,7 @@ def _parse_results(
13701375 for probe_name , score_data in combined ["scores" ].items ()
13711376 if probe_name != "_overall"
13721377 )
1373- overall_score = round ((total_vulnerable / total_attempts ) * 100 , 2 )
1378+ overall_score = self . _pct_to_ratio ((total_vulnerable / total_attempts ) * 100 )
13741379
13751380 num_examples = overall_summary .get ("total_attempts" , total_attempts )
13761381 try :
@@ -1531,7 +1536,7 @@ def main(adapter_cls: type[GarakAdapter] = GarakAdapter) -> None:
15311536
15321537 results = adapter .run_benchmark_job (adapter .job_spec , callbacks )
15331538 logger .info (f"Job completed successfully: { results .id } " )
1534- logger .info (f"Overall attack success rate: { results .overall_score } % " )
1539+ logger .info (f"Overall attack success rate (ratio) : { results .overall_score } " )
15351540
15361541 callbacks .report_results (results )
15371542 sys .exit (0 )
0 commit comments