File size: 655 Bytes
19e2659 0a4290b daad8af 19e2659 0a4290b 19e2659 0a4290b 19e2659 0a4290b 19e2659 0a4290b 19e2659 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from transformers import pipeline
import gradio as gr
# List of NER models
models = ["dslim/bert-base-NER", "dslim/bert-base-NER-uncased", "dslim/bert-large-NER"]
def ner(text, model_choice):
ner_pipeline = pipeline("ner", model=model_choice)
output = ner_pipeline(text)
return {"text": text, "entities": output}
examples = [
"Does Chicago have any stores and does Joe live here?",
]
demo = gr.Interface(
fn=ner,
inputs=[
gr.Textbox(placeholder="Enter sentence here..."),
gr.Dropdown(choices=models, label="Choose NER Model"),
],
outputs=gr.HighlightedText(),
examples=examples,
)
demo.launch()
|