Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -281,7 +281,7 @@ def visualize_logprobs(json_input, chunk=0, chunk_size=100):
|
|
| 281 |
logger.error("Visualization failed: %s (Input: %s)", str(e), json_input[:100] + "..." if len(json_input) > 100 else json_input)
|
| 282 |
return (create_empty_figure("Log Probabilities of Generated Tokens"), None, "No finite log probabilities to display.", create_empty_figure("Top Token Log Probabilities"), create_empty_figure("Significant Probability Drops"), 1, 0)
|
| 283 |
|
| 284 |
-
# Analysis functions for detecting correct vs. incorrect traces
|
| 285 |
def analyze_confidence_signature(logprobs, tokens):
|
| 286 |
if not logprobs or not tokens:
|
| 287 |
return "No data for confidence signature analysis.", None
|
|
@@ -573,7 +573,10 @@ with gr.Blocks(title="Log Probability Visualizer") as app:
|
|
| 573 |
|
| 574 |
# Trigger precomputation when chunk changes (via button clicks or initial load)
|
| 575 |
def trigger_precomputation(json_input, current_chunk):
|
| 576 |
-
|
|
|
|
|
|
|
|
|
|
| 577 |
return gr.update(value=current_chunk)
|
| 578 |
|
| 579 |
# Use a dummy event to trigger precomputation on chunk change (simplified for Gradio)
|
|
|
|
| 281 |
logger.error("Visualization failed: %s (Input: %s)", str(e), json_input[:100] + "..." if len(json_input) > 100 else json_input)
|
| 282 |
return (create_empty_figure("Log Probabilities of Generated Tokens"), None, "No finite log probabilities to display.", create_empty_figure("Top Token Log Probabilities"), create_empty_figure("Significant Probability Drops"), 1, 0)
|
| 283 |
|
| 284 |
+
# Analysis functions for detecting correct vs. incorrect traces (unchanged from previous)
|
| 285 |
def analyze_confidence_signature(logprobs, tokens):
|
| 286 |
if not logprobs or not tokens:
|
| 287 |
return "No data for confidence signature analysis.", None
|
|
|
|
| 573 |
|
| 574 |
# Trigger precomputation when chunk changes (via button clicks or initial load)
|
| 575 |
def trigger_precomputation(json_input, current_chunk):
|
| 576 |
+
try:
|
| 577 |
+
asyncio.create_task(precompute_next_chunk(json_input, current_chunk, None))
|
| 578 |
+
except Exception as e:
|
| 579 |
+
logger.error("Precomputation trigger failed: %s", str(e))
|
| 580 |
return gr.update(value=current_chunk)
|
| 581 |
|
| 582 |
# Use a dummy event to trigger precomputation on chunk change (simplified for Gradio)
|