File size: 1,177 Bytes
372cb74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import torch
import streamlit as st
from transformers import pipeline
from random import choice

with open("sentences.pt", 'rb') as f:
    sentences = torch.load(f)

baseline_classifier = pipeline(
    model="Dagobert42/mobilebert-uncased-biored-finetuned-ner",
    task="ner",
    aggregation_strategy="simple"
    )
augmented_classifier = pipeline(
    model="Dagobert42/mobilebert-uncased-biored-augmented-ner",
    task="ner",
    aggregation_strategy="simple"
    )

st.title("Semantic Frame Augmentation")
st.caption("Analysing difficult low-resource domains with only a handful of examples")

st.write("This space uses a googel/mobilebert-uncased model for named entity ")
augment = st.toggle('Use augmented model for ', value=False)

sentence = choice(sentences)

if augment:
    st.write("with augmentation:")
    tokens = augmented_classifier(sentence)
else:
    st.write("without augmentation:")
    tokens = baseline_classifier(sentence)

txt = st.text_area(
    "Text to analyze",
    sentence,
    max_chars=500
    )

st.subheader("Entity analysis:")
for token in tokens:
    st.write(token['entity_group'])
    st.write(sentence[token["start"] : token["end"]])