File size: 738 Bytes
959ded8
bb43fc4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

def ner_interface(text):
    """
    Gradio interface function for NER pipeline.
    """
    pipe = pipeline("ner", model="NbAiLab/nb-bert-base-ner", aggregation_strategy="simple")
    results = pipe(text)
    df_results = pd.DataFrame(results)
    return df_results

# Create the Gradio interface
iface = gr.Interface(
    fn=ner_interface,
    inputs=gr.Textbox(lines=10, label="Enter text for NER"),
    outputs=gr.DataFrame(label="Extracted Entities"),
    title="Named Entity Recognition (NER) Pipeline",
    description="Extracts entities (like persons, organizations, and locations) from text using the NbAiLab/nb-bert-base-ner model."
)

# Launch the interface
iface.launch()