Spaces:
Runtime error
Runtime error
add skeleton
Browse files- app.py +17 -0
- corpus.py +5 -0
- requirements.txt +0 -0
- single.py +45 -0
- static/logo.png +0 -0
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import single
|
3 |
+
import corpus
|
4 |
+
from PIL import Image
|
5 |
+
|
6 |
+
PAGES = {
|
7 |
+
"Single Explanation": single,
|
8 |
+
"Corpus Explanation": corpus,
|
9 |
+
}
|
10 |
+
|
11 |
+
st.sidebar.title("Explore ferret!")
|
12 |
+
|
13 |
+
logo = Image.open("static/logo.png")
|
14 |
+
st.sidebar.image(logo, caption="ferret")
|
15 |
+
|
16 |
+
page = st.sidebar.radio("", list(PAGES.keys()))
|
17 |
+
PAGES[page].body()
|
corpus.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
|
4 |
+
def body():
|
5 |
+
st.text("TBD")
|
requirements.txt
ADDED
File without changes
|
single.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
+
|
4 |
+
|
5 |
+
@st.cache()
|
6 |
+
def get_model(model_name):
|
7 |
+
return AutoModelForSequenceClassification.from_pretrained(model_name)
|
8 |
+
|
9 |
+
|
10 |
+
@st.cache()
|
11 |
+
def get_tokenizer(tokenizer_name):
|
12 |
+
return AutoTokenizer.from_pretrained(tokenizer_name, use_fast=True)
|
13 |
+
|
14 |
+
|
15 |
+
def body():
|
16 |
+
|
17 |
+
st.title("Evaluate using *ferret* !")
|
18 |
+
|
19 |
+
st.markdown(
|
20 |
+
"""
|
21 |
+
|
22 |
+
### 👋 Hi!
|
23 |
+
|
24 |
+
Insert down below your text, choose a model and fire up ferret. We will use
|
25 |
+
*ferret* to:
|
26 |
+
1. produce explanations with all supported methods
|
27 |
+
2. evaluate explanations on state-of-the-art **faithfulness metrics**.
|
28 |
+
"""
|
29 |
+
)
|
30 |
+
|
31 |
+
col1, col2 = st.columns([1, 1])
|
32 |
+
with col1:
|
33 |
+
model_name = st.text_input("HF Model", "g8a9/bert-base-cased_ami18")
|
34 |
+
with col2:
|
35 |
+
tokenizer_name = st.text_input("HF Tokenizer", "bert-base-cased")
|
36 |
+
|
37 |
+
text = st.text_input("Text")
|
38 |
+
|
39 |
+
compute = st.button("Compute")
|
40 |
+
|
41 |
+
if text and compute and model_name and tokenizer_name:
|
42 |
+
st.text("hellp")
|
43 |
+
|
44 |
+
# model = get_model(model_name)
|
45 |
+
# tokenizer = get_tokenizer(tokenizer_name)
|
static/logo.png
ADDED