sileod commited on
Commit
816c523
·
verified ·
1 Parent(s): fb5842d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -12,15 +12,20 @@ def process_input(text_input, labels_or_premise, mode):
12
  results = {label: score for label, score in zip(prediction['labels'], prediction['scores'])}
13
  return results, ''
14
  else: # NLI mode
15
- prediction = nli_classifier([{"text": text_input, "text_pair": labels_or_premise}])
16
- results = {pred['label']: pred['score'] for pred in prediction}
 
 
 
 
 
17
  return results, ''
18
 
19
  def update_interface(mode):
20
  if mode == "Zero-Shot Classification":
21
  return gr.update(label="🏷️ Categories", placeholder="Enter comma-separated categories...")
22
  else:
23
- return gr.update(label="Hypothesis", placeholder="Enter a hypothesis to compare with the premise...")
24
 
25
  with gr.Blocks() as demo:
26
  gr.Markdown("# 🤖 ModernBERT Text Analysis")
 
12
  results = {label: score for label, score in zip(prediction['labels'], prediction['scores'])}
13
  return results, ''
14
  else: # NLI mode
15
+ prediction = nli_classifier([{"text": text_input, "text_pair": labels_or_premise}])[0]
16
+ # Force showing all three labels
17
+ results = {
18
+ "entailment": prediction.get("score", 0) if prediction.get("label") == "entailment" else 0,
19
+ "contradiction": prediction.get("score", 0) if prediction.get("label") == "contradiction" else 0,
20
+ "neutral": prediction.get("score", 0) if prediction.get("label") == "neutral" else 0
21
+ }
22
  return results, ''
23
 
24
  def update_interface(mode):
25
  if mode == "Zero-Shot Classification":
26
  return gr.update(label="🏷️ Categories", placeholder="Enter comma-separated categories...")
27
  else:
28
+ return gr.update(label="🔎 Hypothesis", placeholder="Enter a hypothesis to compare with the premise...")
29
 
30
  with gr.Blocks() as demo:
31
  gr.Markdown("# 🤖 ModernBERT Text Analysis")