codelion commited on
Commit
9970afb
·
verified ·
1 Parent(s): 9e4da33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -65,7 +65,7 @@ def ensure_float(value):
65
  return None
66
 
67
  # Function to process and visualize log probs with multiple analyses
68
- def visualize_logprobs(json_input, prob_filter=-float('inf')):
69
  try:
70
  # Parse the input (handles both JSON and Python dictionaries)
71
  data = parse_input(json_input)
@@ -113,7 +113,7 @@ def visualize_logprobs(json_input, prob_filter=-float('inf')):
113
 
114
  # If no valid data after filtering, return error messages
115
  if not logprobs:
116
- return "No finite log probabilities to visualize after filtering.", None, None, None, None, None, None, None, None, None, None
117
 
118
  # 1. Main Log Probability Plot (with click for tokens)
119
  fig_main, ax_main = plt.subplots(figsize=(10, 5))
@@ -534,7 +534,7 @@ with gr.Blocks(title="Log Probability Visualizer") as app:
534
  lines=10,
535
  placeholder="Paste your JSON (e.g., {\"content\": [...]}) or Python dict (e.g., {'content': [...]}) here...",
536
  )
537
- prob_filter = gr.Slider(minimum=-float('inf'), maximum=0, value=-float('inf'), label="Log Probability Filter (≥)")
538
 
539
  with gr.Row():
540
  plot_output = gr.HTML(label="Log Probability Plot (Click for Tokens)")
 
65
  return None
66
 
67
  # Function to process and visualize log probs with multiple analyses
68
+ def visualize_logprobs(json_input, prob_filter=-1e9): # Changed -float('inf') to -1e9
69
  try:
70
  # Parse the input (handles both JSON and Python dictionaries)
71
  data = parse_input(json_input)
 
113
 
114
  # If no valid data after filtering, return error messages
115
  if not logprobs:
116
+ return ("No finite log probabilities to visualize after filtering.", None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)
117
 
118
  # 1. Main Log Probability Plot (with click for tokens)
119
  fig_main, ax_main = plt.subplots(figsize=(10, 5))
 
534
  lines=10,
535
  placeholder="Paste your JSON (e.g., {\"content\": [...]}) or Python dict (e.g., {'content': [...]}) here...",
536
  )
537
+ prob_filter = gr.Slider(minimum=-1e9, maximum=0, value=-1e9, label="Log Probability Filter (≥)") # Changed -float('inf') to -1e9
538
 
539
  with gr.Row():
540
  plot_output = gr.HTML(label="Log Probability Plot (Click for Tokens)")