Skip to content

Commit 38307e7

Browse files
Updated plots
1 parent 24a54ec commit 38307e7

2 files changed

Lines changed: 44 additions & 21 deletions

File tree

benchmarks/_plotter_combined.py

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ def __plot_roc(
208208
vectorq_local_fpr_values = []
209209

210210
for delta in vectorq_local_deltas:
211+
if delta == 0.01:
212+
continue
213+
211214
df = vectorq_local_data_frames[delta]
212215

213216
tpr = compute_recall_score(tp=df["tp_list"], fn=df["fn_list"])
@@ -228,9 +231,9 @@ def __plot_roc(
228231
markersize=8,
229232
)
230233

231-
for i, delta in enumerate(vectorq_local_deltas):
234+
for i, _ in enumerate(vectorq_local_tpr_values):
232235
if i == 0 or i == len(vectorq_local_deltas) - 1:
233-
label = f"{delta:.2f}"
236+
label = f"{vectorq_local_deltas[i]:.2f}"
234237
else:
235238
label = None
236239
plt.annotate(
@@ -349,6 +352,9 @@ def __plot_precision_vs_recall(
349352
vectorq_local_recall_values = []
350353

351354
for delta in vectorq_local_deltas:
355+
if delta == 0.01:
356+
continue
357+
352358
df = vectorq_local_data_frames[delta]
353359
precision = compute_precision_score(tp=df["tp_list"], fp=df["fp_list"])
354360
recall = compute_recall_score(tp=df["tp_list"], fn=df["fn_list"])
@@ -367,9 +373,9 @@ def __plot_precision_vs_recall(
367373
markersize=8,
368374
)
369375

370-
for i, delta in enumerate(vectorq_local_deltas):
376+
for i, _ in enumerate(vectorq_local_precision_values):
371377
if i == 0 or i == len(vectorq_local_deltas) - 1:
372-
label = f"{delta:.2f}"
378+
label = f"{vectorq_local_deltas[i]:.2f}"
373379
else:
374380
label = None
375381
plt.annotate(
@@ -444,22 +450,23 @@ def __plot_avg_latency_vs_error_rate(
444450
static_thresholds = sorted(static_data_frames.keys())
445451
static_error_rates = []
446452
static_latencies = []
453+
454+
avg_latency_no_cache = 0.0
447455

448456
for threshold in static_thresholds:
449457
df = static_data_frames[threshold]
450458

451459
error_rate = compute_error_rate_score(fp=df["fp_list"])
452-
453460
avg_latency = compute_avg_latency_score(latency_list=df["latency_vectorq_list"])
454-
avg_latency = avg_latency / 60.0
455-
456461
static_error_rates.append(error_rate)
457462
static_latencies.append(avg_latency)
463+
464+
avg_latency_no_cache = compute_avg_latency_score(latency_list=df["latency_direct_list"])
458465

459466
if static_thresholds:
460467
plt.plot(
461-
static_error_rates,
462468
static_latencies,
469+
static_error_rates,
463470
"o-",
464471
color="blue",
465472
linewidth=2,
@@ -479,17 +486,26 @@ def __plot_avg_latency_vs_error_rate(
479486
fontsize=font_size - 4,
480487
)
481488

489+
plt.axvline(
490+
x=avg_latency_no_cache,
491+
color='grey',
492+
linestyle='--',
493+
linewidth=2,
494+
label='No Cache'
495+
)
496+
482497
vectorq_local_deltas = sorted(vectorq_local_data_frames.keys())
483498
vectorq_local_error_rates = []
484499
vectorq_local_latencies = []
485500

486501
for delta in vectorq_local_deltas:
502+
if delta == 0.01:
503+
continue
504+
487505
df = vectorq_local_data_frames[delta]
488506

489507
error_rate = compute_error_rate_score(fp=df["fp_list"])
490-
491508
avg_latency = compute_avg_latency_score(latency_list=df["latency_vectorq_list"])
492-
493509
vectorq_local_error_rates.append(error_rate)
494510
vectorq_local_latencies.append(avg_latency)
495511

@@ -504,13 +520,15 @@ def __plot_avg_latency_vs_error_rate(
504520
markersize=8,
505521
)
506522

507-
for i, delta in enumerate(vectorq_local_deltas):
523+
for i, _ in enumerate(vectorq_local_latencies):
524+
if i == 0:
525+
continue
526+
508527
if i == 0 or i == len(vectorq_local_deltas) - 1:
509-
label = f"{delta:.2f}"
528+
label = f"{vectorq_local_deltas[i]:.2f}"
510529
plt.annotate(
511530
label,
512531
(vectorq_local_error_rates[i], vectorq_local_latencies[i]),
513-
textcoords="offset points",
514532
xytext=(0, 10),
515533
ha="center",
516534
fontsize=font_size - 4,
@@ -604,7 +622,7 @@ def __plot_cache_hit_vs_error_rate(
604622
)
605623

606624
for i, threshold in enumerate(static_thresholds):
607-
if i == 0 or i == len(static_thresholds) - 1:
625+
if i == 0 or i == len(static_thresholds) - 2:
608626
label = f"{threshold:.2f}"
609627
else:
610628
label = None
@@ -622,6 +640,9 @@ def __plot_cache_hit_vs_error_rate(
622640
vectorq_local_error_rates = []
623641

624642
for delta in vectorq_local_deltas:
643+
if delta == 0.01:
644+
continue
645+
625646
df = vectorq_local_data_frames[delta]
626647

627648
cache_hit_rate = compute_cache_hit_rate_score(
@@ -644,15 +665,17 @@ def __plot_cache_hit_vs_error_rate(
644665
markersize=8,
645666
)
646667

647-
for i, delta in enumerate(vectorq_local_deltas):
668+
for i, _ in enumerate(vectorq_local_error_rates):
669+
if i == 0:
670+
continue
671+
648672
if i == 0 or i == len(vectorq_local_deltas) - 1:
649-
label = f"{delta:.2f}"
673+
label = f"{vectorq_local_deltas[i]:.2f}"
650674
else:
651675
label = None
652676
plt.annotate(
653677
label,
654678
(vectorq_local_error_rates[i], vectorq_local_cache_hit_rates[i]),
655-
textcoords="offset points",
656679
xytext=(0, 10),
657680
ha="center",
658681
fontsize=font_size - 4,
@@ -704,7 +727,7 @@ def __plot_cache_hit_vs_error_rate(
704727
plt.grid(True, linestyle="--", alpha=0.7)
705728
plt.legend(loc="best", fontsize=font_size - 2)
706729
plt.tick_params(axis="both", labelsize=font_size - 2)
707-
plt.xlim(0, 1)
730+
plt.xlim(0, 0.3)
708731
plt.ylim(0, 1)
709732

710733
filename = results_dir + f"/cache_hit_vs_error_rate_{timestamp}.pdf"
@@ -720,7 +743,7 @@ def __plot_cache_hit_vs_error_rate_vs_sample_size(
720743
timestamp: str,
721744
font_size: int,
722745
):
723-
target_deltas = [0.01, 0.02]
746+
target_deltas = [0.02, 0.03]
724747

725748
# Baseline 1) VectorQ (Local)
726749
vectorq_local_error_rates = []

benchmarks/benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
########################################################################################################################
4949

5050
# Benchmark Config
51-
MAX_SAMPLES: int = 10000
51+
MAX_SAMPLES: int = 45000
5252
CONFIDENCE_INTERVALS_ITERATIONS: int = 1
5353
EMBEDDING_MODEL_1 = (
5454
"embedding_1",
@@ -86,7 +86,7 @@
8686
"ecommerce_dataset.json",
8787
"semantic_prompt_cache_benchmark.json",
8888
]
89-
DATASETS_TO_EXCLUDE: List[str] = [DATASETS[0], DATASETS[1], DATASETS[2]]
89+
DATASETS_TO_EXCLUDE: List[str] = [DATASETS[1], DATASETS[2]]
9090

9191
embedding_models: List[Tuple[str, str, str, int]] = [
9292
EMBEDDING_MODEL_1,

0 commit comments

Comments
 (0)