Spaces:
Sleeping
Sleeping
Ajaykanth Maddi commited on
Commit ·
99ce3fc
1
Parent(s): 09834b6
Code Changes - Reranking Implementation
Browse files
app.py
CHANGED
|
@@ -114,6 +114,67 @@ def get_info_from_sample_questions(subset, question):
|
|
| 114 |
return "No answer found.", "No metrics found."
|
| 115 |
|
| 116 |
def plot_subset_metrics(subset_name):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
summary = ragbench_details[subset_name]["summary"]
|
| 118 |
|
| 119 |
# Create a DataFrame for plotting
|
|
|
|
| 114 |
return "No answer found.", "No metrics found."
|
| 115 |
|
| 116 |
def plot_subset_metrics(subset_name):
|
| 117 |
+
"""Generate a bar plot of key metrics for a given subset with proper title display."""
|
| 118 |
+
try:
|
| 119 |
+
summary = ragbench_details[subset_name]["summary"]
|
| 120 |
+
|
| 121 |
+
# Metrics to plot
|
| 122 |
+
metrics = {
|
| 123 |
+
'Entries': 'Total Entries',
|
| 124 |
+
'TotalDocs': 'Total Documents',
|
| 125 |
+
'TotalUniqueIds': 'Unique IDs',
|
| 126 |
+
'TotalUniqueDocs': 'Unique Documents',
|
| 127 |
+
'UniqueDocsPercent': '% Unique Docs'
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
# Prepare data
|
| 131 |
+
display_names = list(metrics.values())
|
| 132 |
+
values = [summary.get(metric, 0) for metric in metrics.keys()]
|
| 133 |
+
|
| 134 |
+
# Create figure with constrained layout
|
| 135 |
+
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
|
| 136 |
+
|
| 137 |
+
# Plot bars
|
| 138 |
+
bars = ax.bar(display_names, values, color='skyblue')
|
| 139 |
+
|
| 140 |
+
# Add value labels
|
| 141 |
+
ax.bar_label(bars, fmt='%.0f', padding=3, fontsize=9)
|
| 142 |
+
|
| 143 |
+
# Title adjustments
|
| 144 |
+
title = f"Dataset Metrics: {subset_name}"
|
| 145 |
+
if 'Domain' in summary:
|
| 146 |
+
title += f"\nDomain: {summary['Domain']}"
|
| 147 |
+
|
| 148 |
+
ax.set_title(title, fontsize=12, pad=20, loc='left') # Explicit title positioning
|
| 149 |
+
|
| 150 |
+
# Axis formatting
|
| 151 |
+
ax.set_ylabel("Count", fontsize=10)
|
| 152 |
+
ax.grid(axis='y', linestyle=':', alpha=0.6)
|
| 153 |
+
|
| 154 |
+
# Rotate x-labels
|
| 155 |
+
ax.set_xticks(range(len(display_names)))
|
| 156 |
+
ax.set_xticklabels(display_names, rotation=25, ha='right', fontsize=9)
|
| 157 |
+
|
| 158 |
+
# Special handling for percentage value
|
| 159 |
+
if 'UniqueDocsPercent' in summary:
|
| 160 |
+
ax.text(
|
| 161 |
+
len(metrics)-1,
|
| 162 |
+
summary['UniqueDocsPercent'],
|
| 163 |
+
f"{summary['UniqueDocsPercent']}%",
|
| 164 |
+
ha='center',
|
| 165 |
+
va='bottom',
|
| 166 |
+
fontsize=10,
|
| 167 |
+
bbox=dict(facecolor='white', alpha=0.8, edgecolor='none')
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
return fig
|
| 171 |
+
|
| 172 |
+
except KeyError:
|
| 173 |
+
print(f"Error: Subset '{subset_name}' not found")
|
| 174 |
+
except Exception as e:
|
| 175 |
+
print(f"Plotting error: {str(e)}")
|
| 176 |
+
|
| 177 |
+
def plot_subset_metrics_old(subset_name):
|
| 178 |
summary = ragbench_details[subset_name]["summary"]
|
| 179 |
|
| 180 |
# Create a DataFrame for plotting
|