Spaces:
Sleeping
Sleeping
PereLluis13
commited on
Commit
•
a419564
1
Parent(s):
5901d27
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
|
4 |
from time import time
|
5 |
import torch
|
6 |
|
7 |
-
@st.
|
8 |
allow_output_mutation=True,
|
9 |
hash_funcs={
|
10 |
AutoTokenizer: lambda x: None,
|
@@ -65,7 +65,7 @@ st.markdown("""This is a demo for the Findings of EMNLP 2021 paper [REBEL: Relat
|
|
65 |
|
66 |
lan = st.selectbox(
|
67 |
'Select a Language',
|
68 |
-
('ar', 'ca', 'de', 'el', 'en', 'es', 'fr', 'hi', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'vi', 'zh'))
|
69 |
|
70 |
_Tokens = {'en': 'en_XX', 'de': 'de_DE', 'ca': 'ca_XX', 'ar': 'ar_AR', 'el': 'el_EL', 'it': 'it_IT', 'ja': 'ja_XX', 'ko': 'ko_KR', 'hi': 'hi_IN', 'pt': 'pt_XX', 'ru': 'ru_RU', 'pl': 'pl_PL', 'zh': 'zh_CN', 'fr': 'fr_XX', 'vi': 'vi_VN', 'sv':'sv_SE'}
|
71 |
|
@@ -73,11 +73,11 @@ tokenizer, model, dataset = load_models(lan)
|
|
73 |
|
74 |
agree = st.checkbox('Free input', False)
|
75 |
if agree:
|
76 |
-
text = st.text_input('Input text', 'Els Red Hot Chili Peppers es van formar a Los Angeles per Kiedis, Flea, el guitarrista Hillel Slovak i el bateria Jack Irons.')
|
77 |
print(text)
|
78 |
else:
|
79 |
dataset_example = st.slider('dataset id', 0, 1000, 0)
|
80 |
-
text = dataset[dataset_example]['
|
81 |
length_penalty = st.slider('length_penalty', 0, 10, 0)
|
82 |
num_beams = st.slider('num_beams', 1, 20, 3)
|
83 |
num_return_sequences = st.slider('num_return_sequences', 1, num_beams, 2)
|
@@ -105,8 +105,7 @@ st.write(text)
|
|
105 |
|
106 |
if not agree:
|
107 |
st.title('Silver output')
|
108 |
-
st.write(dataset[dataset_example]['
|
109 |
-
st.write(extract_triplets_typed(dataset[dataset_example]['triplets']))
|
110 |
|
111 |
st.title('Prediction text')
|
112 |
decoded_preds = [text.replace('<s>', '').replace('</s>', '').replace('<pad>', '') for text in decoded_preds]
|
|
|
4 |
from time import time
|
5 |
import torch
|
6 |
|
7 |
+
@st.cache_reesources(
|
8 |
allow_output_mutation=True,
|
9 |
hash_funcs={
|
10 |
AutoTokenizer: lambda x: None,
|
|
|
65 |
|
66 |
lan = st.selectbox(
|
67 |
'Select a Language',
|
68 |
+
('ar', 'ca', 'de', 'el', 'en', 'es', 'fr', 'hi', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'vi', 'zh'), index=1)
|
69 |
|
70 |
_Tokens = {'en': 'en_XX', 'de': 'de_DE', 'ca': 'ca_XX', 'ar': 'ar_AR', 'el': 'el_EL', 'it': 'it_IT', 'ja': 'ja_XX', 'ko': 'ko_KR', 'hi': 'hi_IN', 'pt': 'pt_XX', 'ru': 'ru_RU', 'pl': 'pl_PL', 'zh': 'zh_CN', 'fr': 'fr_XX', 'vi': 'vi_VN', 'sv':'sv_SE'}
|
71 |
|
|
|
73 |
|
74 |
agree = st.checkbox('Free input', False)
|
75 |
if agree:
|
76 |
+
text = st.text_input('Input text (current example in catalan)', 'Els Red Hot Chili Peppers es van formar a Los Angeles per Kiedis, Flea, el guitarrista Hillel Slovak i el bateria Jack Irons.')
|
77 |
print(text)
|
78 |
else:
|
79 |
dataset_example = st.slider('dataset id', 0, 1000, 0)
|
80 |
+
text = dataset[dataset_example]['text']
|
81 |
length_penalty = st.slider('length_penalty', 0, 10, 0)
|
82 |
num_beams = st.slider('num_beams', 1, 20, 3)
|
83 |
num_return_sequences = st.slider('num_return_sequences', 1, num_beams, 2)
|
|
|
105 |
|
106 |
if not agree:
|
107 |
st.title('Silver output')
|
108 |
+
st.write(dataset[dataset_example]['relations'])
|
|
|
109 |
|
110 |
st.title('Prediction text')
|
111 |
decoded_preds = [text.replace('<s>', '').replace('</s>', '').replace('<pad>', '') for text in decoded_preds]
|