Spaces:
Runtime error
Runtime error
Commit
·
698432b
1
Parent(s):
558653a
updated app
Browse files
app.py
CHANGED
@@ -2,7 +2,12 @@ import streamlit as st
|
|
2 |
from transformers import AutoTokenizer,AutoModelForSeq2SeqLM
|
3 |
|
4 |
@st.cache(persist=True)
|
5 |
-
def load_model(input_complex_sentence,model
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
tokenized_sentence = tokenizer(input_complex_sentence,return_tensors="pt")
|
8 |
result = model.generate(tokenized_sentence['input_ids'],attention_mask = tokenized_sentence['attention_mask'],max_length=256,num_beams=5)
|
@@ -12,22 +17,6 @@ def load_model(input_complex_sentence,model, tokenizer):
|
|
12 |
|
13 |
def main():
|
14 |
|
15 |
-
t5_base_path = "flax-community/t5-base-wikisplit"
|
16 |
-
t5_base_tokenizer = AutoTokenizer.from_pretrained(t5_base_path)
|
17 |
-
t5_base_model = AutoModelForSeq2SeqLM.from_pretrained(t5_base_path)
|
18 |
-
|
19 |
-
t5_v1_1_base_path = "flax-community/t5-v1_1-base-wikisplit"
|
20 |
-
t5_v1_1_base_tokenizer = AutoTokenizer.from_pretrained(t5_v1_1_base_path)
|
21 |
-
t5_v1_1_base_model = AutoModelForSeq2SeqLM.from_pretrained(t5_v1_1_base_path)
|
22 |
-
|
23 |
-
byt5_base_path = "flax-community/byt5-base-wikisplit"
|
24 |
-
byt5_base_tokenizer = AutoTokenizer.from_pretrained(byt5_base_path)
|
25 |
-
byt5_base_model = AutoModelForSeq2SeqLM.from_pretrained(byt5_base_path)
|
26 |
-
|
27 |
-
t5_large_path = "flax-community/t5-large-wikisplit"
|
28 |
-
t5_large_tokenizer = AutoTokenizer.from_pretrained(t5_large_path)
|
29 |
-
t5_large_model = AutoModelForSeq2SeqLM.from_pretrained(t5_large_path)
|
30 |
-
|
31 |
st.title("✂️ Sentence Split in English using T5 variants")
|
32 |
st.write("Sentence Split is the task of dividing a long Sentence into multiple Sentences")
|
33 |
|
@@ -40,15 +29,8 @@ def main():
|
|
40 |
input_complex_sentence = st.text_area("Please type a long Sentence to split",example)
|
41 |
|
42 |
if st.button('Simplify'):
|
43 |
-
|
44 |
-
|
45 |
-
generated_sentence = load_model(input_complex_sentence, t5_base_model, t5_base_tokenizer)
|
46 |
-
elif model=="t5-v1_1-base-wikisplit":
|
47 |
-
generated_sentence = load_model(input_complex_sentence, t5_v1_1_base_model, t5_v1_1_base_tokenizer)
|
48 |
-
elif model=="byt5-base-wikisplit":
|
49 |
-
generated_sentence = load_model(input_complex_sentence, byt5_base_model, byt5_base_tokenizer)
|
50 |
-
else:
|
51 |
-
generated_sentence = load_model(input_complex_sentence, t5_large_model, t5_large_tokenizer)
|
52 |
st.write(generated_sentence)
|
53 |
|
54 |
|
|
|
2 |
from transformers import AutoTokenizer,AutoModelForSeq2SeqLM
|
3 |
|
4 |
@st.cache(persist=True)
|
5 |
+
def load_model(input_complex_sentence,model):
|
6 |
+
|
7 |
+
base_path = "flax-community/"
|
8 |
+
model_path = base_path + model
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
10 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
11 |
|
12 |
tokenized_sentence = tokenizer(input_complex_sentence,return_tensors="pt")
|
13 |
result = model.generate(tokenized_sentence['input_ids'],attention_mask = tokenized_sentence['attention_mask'],max_length=256,num_beams=5)
|
|
|
17 |
|
18 |
def main():
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
st.title("✂️ Sentence Split in English using T5 variants")
|
21 |
st.write("Sentence Split is the task of dividing a long Sentence into multiple Sentences")
|
22 |
|
|
|
29 |
input_complex_sentence = st.text_area("Please type a long Sentence to split",example)
|
30 |
|
31 |
if st.button('Simplify'):
|
32 |
+
|
33 |
+
generated_sentence = load_model(input_complex_sentence, model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
st.write(generated_sentence)
|
35 |
|
36 |
|