File size: 1,814 Bytes
372cb74
e8a5261
372cb74
00a6def
ec77f50
00a6def
372cb74
e8a5261
 
 
 
 
 
ec77f50
 
 
6015c85
372cb74
 
460e2cc
372cb74
52bd259
d026301
0c62ce7
 
460e2cc
372cb74
e8a5261
52bd259
e8a5261
 
00a6def
4330a70
52bd259
460e2cc
 
9b720a1
 
 
460e2cc
 
52bd259
e8a5261
52bd259
460e2cc
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 streamlit as st
from streamlit import session_state
from random import choice
from annotated_text import annotated_text
from resources import *
from helpers import *

if "counter" not in session_state:
    session_state.counter = 0

if "augment" not in session_state:
    session_state.augment = False

base_model = "xlnet-base-cased"
sentences = load_sentences()
baseline_classifier = load_model(f"Dagobert42/{base_model}-biored-finetuned")
augmented_classifier = load_model(f"Dagobert42/{base_model}-biored-augmented-super")

st.title("Semantic Frame Augmentation")
st.subheader("Analysing challenging domains with only a handful of examples")

st.write(f"""This space uses models based on [XLNet](https://huggingface.co/xlnet-base-cased) to identify medical entities in a text.
The following is a random sentence from [bigbio/biored](https://huggingface.co/datasets/bigbio/biored).
It was tagged by a model which was trained on just 200 examples from the original dataset.
It is very possible that there are some mistakes.
""")

txt = sentences[session_state.counter]

st.write("Example with data augmentation:" if session_state.augment else "Example without data augmentation:")
tokens = augmented_classifier(txt) if session_state.augment else baseline_classifier(txt)

annotated_text(annotate_sentence(txt, tokens))
st.write(annotate_sentence(txt, tokens))

st.write("Now try the augmented model. Hopefully it's a bit better :)")
def refresh_model():
    session_state.augment = not session_state.augment
st.toggle("augmentations on" if session_state.augment else "augmentations off", session_state.augment, on_change=refresh_model)

st.write("Or load another sentence")
def refresh_example():
    session_state.counter += 1
st.button( ":twisted_rightwards_arrows:", on_click=refresh_example)