Spaces:
Running
Running
File size: 19,306 Bytes
c03ae2c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | #!/usr/bin/env python3
"""Gradio dashboard for visualizing analyzed peft issues with time range filtering."""
import json
from datetime import datetime
from pathlib import Path
import gradio as gr
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
ANALYZED_FILE = Path("peft_issues_merged_500.json")
def parse_date(date_str):
"""Parse ISO date string to year-month string."""
try:
dt = datetime.fromisoformat(date_str.replace('Z', '+00:00'))
return dt.strftime('%Y-%m')
except:
return "unknown"
def parse_date_full(date_str):
"""Parse ISO date string to datetime object."""
try:
return datetime.fromisoformat(date_str.replace('Z', '+00:00'))
except:
return datetime.min
def load_data():
"""Load analyzed issues data with date parsing."""
with open(ANALYZED_FILE, "r", encoding="utf-8") as f:
data = json.load(f)
# Add parsed dates
for item in data:
item['year_month'] = parse_date(item.get('created_at', ''))
item['date_obj'] = parse_date_full(item.get('created_at', ''))
return data
def create_dataframe(data):
"""Create a pandas DataFrame from analyzed data."""
df_data = []
for item in data:
df_data.append({
"Issue #": item["number"],
"Title": item["title"][:100] + "..." if len(item["title"]) > 100 else item["title"],
"State": item["state"],
"Date": item.get("year_month", "unknown"),
"Model": item["model"],
"Trainer": item["trainer"],
"PEFT Method": item["peft_method"],
"Training Type": item["training_type"],
"Experience": item["experience_score"],
"Specialties": ", ".join(item["specialties"]) if item["specialties"] != ["none"] else "-",
"URL": item["html_url"],
})
return pd.DataFrame(df_data)
def filter_data(df, model_filter, trainer_filter, peft_filter, training_filter, min_score, max_score, min_month, max_month):
"""Filter dataframe based on user selections including date range."""
if model_filter != "All":
df = df[df["Model"] == model_filter]
if trainer_filter != "All":
df = df[df["Trainer"] == trainer_filter]
if peft_filter != "All":
df = df[df["PEFT Method"] == peft_filter]
if training_filter != "All":
df = df[df["Training Type"] == training_filter]
df = df[(df["Experience"] >= min_score) & (df["Experience"] <= max_score)]
# Date range filtering
df = df[(df["Date"] >= min_month) & (df["Date"] <= max_month)]
return df
def get_unique_values(data, key):
"""Get unique values for a filter dropdown."""
values = sorted(set(item[key] for item in data))
return ["All"] + values
def get_month_range(data):
"""Get min and max month from data."""
months = sorted(set(item.get("year_month", "unknown") for item in data if item.get("year_month") != "unknown"))
if not months:
return ["2023-01", "2026-12"]
return [months[0], months[-1]]
def get_all_months(data):
"""Get all unique months in chronological order."""
months = sorted(set(item.get("year_month", "unknown") for item in data if item.get("year_month") != "unknown"))
return months
def create_peft_method_chart(data):
"""Create PEFT method distribution chart."""
if not data:
return go.Figure()
methods = {}
for item in data:
m = item["peft_method"]
methods[m] = methods.get(m, 0) + 1
df = pd.DataFrame(list(methods.items()), columns=["PEFT Method", "Count"])
fig = px.bar(df, x="PEFT Method", y="Count", title="PEFT Method Distribution",
color="PEFT Method", template="plotly_white")
fig.update_layout(showlegend=False)
return fig
def create_trainer_chart(data):
"""Create trainer framework distribution chart."""
if not data:
return go.Figure()
trainers = {}
for item in data:
t = item["trainer"]
trainers[t] = trainers.get(t, 0) + 1
df = pd.DataFrame(list(trainers.items()), columns=["Trainer", "Count"])
fig = px.pie(df, values="Count", names="Trainer", title="Trainer Framework Distribution",
template="plotly_white")
return fig
def create_training_type_chart(data):
"""Create training type distribution chart."""
if not data:
return go.Figure()
types = {}
for item in data:
t = item["training_type"]
types[t] = types.get(t, 0) + 1
df = pd.DataFrame(list(types.items()), columns=["Training Type", "Count"])
fig = px.bar(df, x="Training Type", y="Count", title="Training Type Distribution",
color="Training Type", template="plotly_white")
fig.update_layout(showlegend=False)
return fig
def create_experience_chart(data):
"""Create experience score histogram."""
if not data:
return go.Figure()
scores = [item["experience_score"] for item in data]
fig = px.histogram(x=scores, nbins=10, title="Experience Score Distribution",
labels={"x": "Experience Score", "y": "Count"},
template="plotly_white")
fig.update_traces(marker_color="steelblue")
return fig
def create_experience_by_method_chart(data):
"""Create average experience score by PEFT method."""
if not data:
return go.Figure()
method_scores = {}
method_counts = {}
for item in data:
m = item["peft_method"]
method_scores[m] = method_scores.get(m, 0) + item["experience_score"]
method_counts[m] = method_counts.get(m, 0) + 1
avg_scores = {m: method_scores[m] / method_counts[m] for m in method_scores}
df = pd.DataFrame(list(avg_scores.items()), columns=["PEFT Method", "Avg Score"])
fig = px.bar(df, x="PEFT Method", y="Avg Score", title="Average Experience Score by PEFT Method",
color="PEFT Method", template="plotly_white")
fig.update_layout(showlegend=False, yaxis_range=[0, 10])
return fig
def create_specialties_chart(data):
"""Create specialties distribution chart."""
if not data:
return go.Figure()
specialties = {}
for item in data:
for s in item["specialties"]:
if s != "none":
specialties[s] = specialties.get(s, 0) + 1
if not specialties:
return go.Figure()
df = pd.DataFrame(list(specialties.items()), columns=["Specialty", "Count"])
fig = px.bar(df, x="Specialty", y="Count", title="Special Technologies Distribution",
color="Specialty", template="plotly_white")
fig.update_layout(showlegend=False)
return fig
def create_model_chart(data):
"""Create model distribution chart."""
if not data:
return go.Figure()
models = {}
for item in data:
m = item["model"]
if m != "unknown":
models[m] = models.get(m, 0) + 1
if not models:
return go.Figure()
df = pd.DataFrame(list(models.items()), columns=["Model", "Count"])
fig = px.bar(df, x="Model", y="Count", title="Model Distribution",
color="Model", template="plotly_white")
fig.update_layout(showlegend=False)
return fig
def create_temporal_chart(data):
"""Create issues over time chart."""
if not data:
return go.Figure()
months = {}
for item in data:
m = item.get("year_month", "unknown")
if m != "unknown":
months[m] = months.get(m, 0) + 1
if not months:
return go.Figure()
sorted_months = sorted(months.items())
df = pd.DataFrame(sorted_months, columns=["Month", "Issues"])
fig = px.line(df, x="Month", y="Issues", title="Issues Over Time",
markers=True, template="plotly_white")
fig.update_layout(xaxis_tickangle=-45)
return fig
def show_issue_details(issue_number, data):
"""Show detailed information for a specific issue."""
for item in data:
if item["number"] == issue_number:
return (
f"**Issue #{item['number']}**: [{item['title']}]({item['html_url']})\n\n"
f"**State**: {item['state']}\n"
f"**Author**: {item['author']}\n"
f"**Created**: {item['created_at'][:10] if item.get('created_at') else 'unknown'}\n"
f"**Labels**: {', '.join(item['labels']) or 'None'}\n\n"
f"**Model**: {item['model']}\n"
f"**Trainer**: {item['trainer']}\n"
f"**PEFT Method**: {item['peft_method']}\n"
f"**Training Type**: {item['training_type']}\n"
f"**Specialties**: {', '.join(item['specialties'])}\n\n"
f"**Experience Score**: {item['experience_score']}/10\n"
f"**Rationale**: {item['experience_rationale']}\n\n"
f"**Confidence**:\n"
f"- Model: {item['confidence'].get('model', 'N/A')}\n"
f"- Trainer: {item['confidence'].get('trainer_framework', item['confidence'].get('trainer', 'N/A'))}\n"
f"- PEFT Method: {item['confidence'].get('peft_method', 'N/A')}\n"
f"- Training Type: {item['confidence'].get('training_type', 'N/A')}\n"
f"- Experience: {item['confidence'].get('experience_score', 'N/A')}\n"
)
return "Issue not found"
def filter_data_by_months(data, min_month, max_month):
"""Filter raw data by month range."""
return [item for item in data if min_month <= item.get("year_month", "unknown") <= max_month]
def build_app():
"""Build the Gradio application."""
data = load_data()
df = create_dataframe(data)
# Get month range
month_range = get_month_range(data)
all_months = get_all_months(data)
with gr.Blocks(title="PEFT Issues Analysis Dashboard") as app:
gr.Markdown("# π PEFT Issues Analysis Dashboard")
gr.Markdown("Analysis of 345 most recent issues from [huggingface/peft](https://github.com/huggingface/peft) β classified by LLM")
# Global date range filter at the top
with gr.Row():
with gr.Column(scale=2):
gr.Markdown("### π
Global Time Range Filter")
with gr.Column(scale=8):
# Use dropdowns for month selection since Gradio slider doesn't support strings well
month_options = all_months
min_month = gr.Dropdown(
choices=month_options,
value=month_range[0],
label="From Month",
allow_custom_value=False
)
max_month = gr.Dropdown(
choices=month_options,
value=month_range[-1],
label="To Month",
allow_custom_value=False
)
with gr.Tabs():
with gr.Tab("π Data Table"):
with gr.Row():
model_filter = gr.Dropdown(
choices=get_unique_values(data, "model"),
value="All",
label="Model"
)
trainer_filter = gr.Dropdown(
choices=get_unique_values(data, "trainer"),
value="All",
label="Trainer"
)
peft_filter = gr.Dropdown(
choices=get_unique_values(data, "peft_method"),
value="All",
label="PEFT Method"
)
training_filter = gr.Dropdown(
choices=get_unique_values(data, "training_type"),
value="All",
label="Training Type"
)
with gr.Row():
min_score = gr.Slider(0, 10, value=0, step=1, label="Min Experience Score")
max_score = gr.Slider(0, 10, value=10, step=1, label="Max Experience Score")
table = gr.DataFrame(
value=df,
headers=["Issue #", "Title", "State", "Date", "Model", "Trainer", "PEFT Method",
"Training Type", "Experience", "Specialties", "URL"],
interactive=False,
wrap=True
)
def update_table(m, t, p, tr, min_s, max_s, min_m, max_m):
filtered = filter_data(df.copy(), m, t, p, tr, min_s, max_s, min_m, max_m)
return filtered
all_filters = [model_filter, trainer_filter, peft_filter, training_filter,
min_score, max_score, min_month, max_month]
for component in all_filters:
component.change(
fn=update_table,
inputs=all_filters,
outputs=table
)
with gr.Tab("π Issue Details"):
issue_number = gr.Number(label="Issue Number", value=data[0]["number"], precision=0)
details = gr.Markdown()
def update_details(num):
return show_issue_details(int(num), data)
issue_number.change(fn=update_details, inputs=issue_number, outputs=details)
details.value = show_issue_details(data[0]["number"], data)
with gr.Tab("π Analytics"):
with gr.Row():
temporal_chart = gr.Plot(value=create_temporal_chart(data))
with gr.Row():
peft_chart = gr.Plot(value=create_peft_method_chart(data))
trainer_chart = gr.Plot(value=create_trainer_chart(data))
with gr.Row():
training_chart = gr.Plot(value=create_training_type_chart(data))
experience_chart = gr.Plot(value=create_experience_chart(data))
with gr.Row():
exp_method_chart = gr.Plot(value=create_experience_by_method_chart(data))
specialties_chart = gr.Plot(value=create_specialties_chart(data))
with gr.Row():
model_chart = gr.Plot(value=create_model_chart(data))
def update_charts(min_m, max_m):
filtered_data = filter_data_by_months(data, min_m, max_m)
return (
create_temporal_chart(filtered_data),
create_peft_method_chart(filtered_data),
create_trainer_chart(filtered_data),
create_training_type_chart(filtered_data),
create_experience_chart(filtered_data),
create_experience_by_method_chart(filtered_data),
create_specialties_chart(filtered_data),
create_model_chart(filtered_data)
)
for component in [min_month, max_month]:
component.change(
fn=update_charts,
inputs=[min_month, max_month],
outputs=[
temporal_chart, peft_chart, trainer_chart,
training_chart, experience_chart,
exp_method_chart, specialties_chart, model_chart
]
)
with gr.Tab("βΉοΈ About"):
gr.Markdown(f"""
## About This Dashboard
This dashboard analyzes 345 recent issues from the [huggingface/peft](https://github.com/huggingface/peft) repository.
**Time Range**: {month_range[0]} to {month_range[1]}
**Total Issues**: {len(data)}
### Data Collection Method
**LLM Classification** (current view):
- All 345 issues classified by a language model reading the full title + body
- More accurate than regex-based extraction, especially for nuanced classifications
- Experience scores and training types are LLM-inferred from context
**Validation Process**:
1. **Static analysis** (rule-based): Extracted via regex patterns
2. **LLM classification**: Language model read all 345 issues in 4 chunks
3. **Comparison**: Identified systematic biases in the static analyzer
4. **Merged results**: This dashboard uses the LLM classification (more accurate)
### Why LLM Classification?
LLM outperforms static analysis on nuanced tasks:
- **Experience score**: LLM understands issue quality, tone, and depth (44.3% agreement with static)
- **Training type**: LLM distinguishes actual training from feature requests (61.2% agreement)
- **PEFT method**: LLM detects context (73.9% agreement)
### Metrics Explained
**Experience Score (0-10)**:
- **Code reproduction**: +2 if runnable code snippet or clear numbered steps
- **Error details**: +2 if actual traceback or error block
- **Environment info**: +2 if actual version numbers or system info table
- **Clarity**: +2 if clear title (4+ words) and substantial body (50+ words)
- **Technical depth**: +2 if 2+ technical terms used in proper context
**Confidence Levels**:
- **High**: Strong evidence in the issue text
- **Medium**: Some evidence or inference
- **Low**: Limited or no evidence
### Known Limitations
- Model detection: Many PEFT issues are framework-level bugs without model mentions
- Trainer detection: Most users don't specify their training framework
- Training type: "unsure" means the issue lacks clear training context (often infrastructure/bug reports)
- LLM may occasionally hallucinate or misread complex technical details
### Data Sources
- Issues fetched via GitHub API on 2026-05-12 (345 issues, most recently updated)
- LLM classification performed on all 345 issues in 4 batches
- Raw data preserved for transparency and re-analysis
""")
return app
if __name__ == "__main__":
app = build_app()
app.launch(share=False, server_name="0.0.0.0", server_port=7860, theme=gr.themes.Soft())
|