Update app.py
Browse files2 unmodified lines345678910111213141516171819202122232425262 unmodified linesdef mask(text):mask_model = pipeline("fill-mask", model="google-bert/bert-base-uncased")# Extract labels (classes) and scores from predictionslabels = [result["label"] for result in mask_model]scores = [result["score"] for result in mask_model]# Find the index of the best prediction (highest score)best_prediction_idx = scores.index(max(scores))# Create a dictionary with resultsresponse_dict = {"Original Text": text,"All Predictions": labels,"Best Prediction": f"**{labels[best_prediction_idx]}** (Score: {scores[best_prediction_idx]:.4f})"}return response_dict# output = mask_model(text)# return output[0]['sequence']# Gradio UIexamples=[['Today I went to [MASK] after I got out of bed.']]2 unmodified lines345678910112 unmodified linesdef mask(text):mask_model = pipeline("fill-mask", model="google-bert/bert-base-uncased")output = mask_model(text)return output[0]['sequence']# Gradio UIexamples=[['Today I went to [MASK] after I got out of bed.']]
app.py+2-17