Commit
·
372cb74
1
Parent(s):
e95aa24
first draft of the space
Browse files- README.md +1 -1
- app.py +44 -0
- requirements.txt +3 -0
- sentences.pt +3 -0
README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
title: Semantic Frame Augmentation
|
| 3 |
emoji: 🚀
|
| 4 |
colorFrom: gray
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.31.1
|
| 8 |
app_file: app.py
|
|
|
|
| 2 |
title: Semantic Frame Augmentation
|
| 3 |
emoji: 🚀
|
| 4 |
colorFrom: gray
|
| 5 |
+
colorTo: yellow
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.31.1
|
| 8 |
app_file: app.py
|
app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
from random import choice
|
| 5 |
+
|
| 6 |
+
with open("sentences.pt", 'rb') as f:
|
| 7 |
+
sentences = torch.load(f)
|
| 8 |
+
|
| 9 |
+
baseline_classifier = pipeline(
|
| 10 |
+
model="Dagobert42/mobilebert-uncased-biored-finetuned-ner",
|
| 11 |
+
task="ner",
|
| 12 |
+
aggregation_strategy="simple"
|
| 13 |
+
)
|
| 14 |
+
augmented_classifier = pipeline(
|
| 15 |
+
model="Dagobert42/mobilebert-uncased-biored-augmented-ner",
|
| 16 |
+
task="ner",
|
| 17 |
+
aggregation_strategy="simple"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
st.title("Semantic Frame Augmentation")
|
| 21 |
+
st.caption("Analysing difficult low-resource domains with only a handful of examples")
|
| 22 |
+
|
| 23 |
+
st.write("This space uses a googel/mobilebert-uncased model for named entity ")
|
| 24 |
+
augment = st.toggle('Use augmented model for ', value=False)
|
| 25 |
+
|
| 26 |
+
sentence = choice(sentences)
|
| 27 |
+
|
| 28 |
+
if augment:
|
| 29 |
+
st.write("with augmentation:")
|
| 30 |
+
tokens = augmented_classifier(sentence)
|
| 31 |
+
else:
|
| 32 |
+
st.write("without augmentation:")
|
| 33 |
+
tokens = baseline_classifier(sentence)
|
| 34 |
+
|
| 35 |
+
txt = st.text_area(
|
| 36 |
+
"Text to analyze",
|
| 37 |
+
sentence,
|
| 38 |
+
max_chars=500
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
st.subheader("Entity analysis:")
|
| 42 |
+
for token in tokens:
|
| 43 |
+
st.write(token['entity_group'])
|
| 44 |
+
st.write(sentence[token["start"] : token["end"]])
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
sentences.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2081e318c8b942b60a480ce78c4b9938e68be208359a43e27c702f7a6d531f43
|
| 3 |
+
size 178144
|