Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| model_name = "emilyalsentzer/Bio_ClinicalBERT" | |
| nlp_pipeline = pipeline("fill-mask", model=model_name) | |
| def medical_chatbot(user_input): | |
| if "[MASK]" not in user_input: | |
| user_input += " [MASK]" | |
| response = nlp_pipeline(user_input) | |
| return {"prediction": response[0]["sequence"], "confidence": response[0]["score"]} | |
| # Create an API interface | |
| interface = gr.Interface(fn=medical_chatbot, inputs="text", outputs="json") | |
| interface.launch(share=True) | |