Malek-AI commited on
Commit
df8416a
·
verified ·
1 Parent(s): 6f75e95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -17
app.py CHANGED
@@ -3,24 +3,9 @@ from transformers import pipeline
3
 
4
  def mask(text):
5
  mask_model = pipeline("fill-mask", model="google-bert/bert-base-uncased")
 
 
6
 
7
- # Extract labels (classes) and scores from predictions
8
- labels = [result["label"] for result in mask_model]
9
- scores = [result["score"] for result in mask_model]
10
-
11
- # Find the index of the best prediction (highest score)
12
- best_prediction_idx = scores.index(max(scores))
13
-
14
- # Create a dictionary with results
15
- response_dict = {
16
- "Original Text": text,
17
- "All Predictions": labels,
18
- "Best Prediction": f"**{labels[best_prediction_idx]}** (Score: {scores[best_prediction_idx]:.4f})"
19
- }
20
-
21
- return response_dict
22
- # output = mask_model(text)
23
- # return output[0]['sequence']
24
 
25
  # Gradio UI
26
  examples=[['Today I went to [MASK] after I got out of bed.']]
 
3
 
4
  def mask(text):
5
  mask_model = pipeline("fill-mask", model="google-bert/bert-base-uncased")
6
+ output = mask_model(text)
7
+ return output[0]['sequence']
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Gradio UI
11
  examples=[['Today I went to [MASK] after I got out of bed.']]