| import gradio as gr | |
| from transformers import pipeline | |
| ner_pipeline = pipeline("ner", model="dslim/bert-base-NER") | |
| examples = [ | |
| "Does Chicago have any stores and does Joe live here?", | |
| ] | |
| def ner(text): | |
| output = ner_pipeline(text) | |
| return {"text": text, "entities": output} | |
| demo = gr.Interface( | |
| ner, | |
| gr.Textbox(placeholder="Enter sentence here..."), | |
| gr.HighlightedText(), | |
| examples=examples, | |
| ) | |
| demo.launch() | |