Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,12 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
if clicked:
|
13 |
-
results = classifier([text])
|
14 |
-
st.json(results)
|
15 |
-
|
16 |
-
if __name__ == "__main__":
|
17 |
-
main()
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
+
from transformers import AutoTokenizer, T5ForConditionalGeneration
|
4 |
|
5 |
+
model_name = "allenai/unifiedqa-t5-small" # you can specify the model size here
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
8 |
|
9 |
+
def run_model(input_string, **generator_args):
|
10 |
+
input_ids = tokenizer.encode(input_string, return_tensors="pt")
|
11 |
+
res = model.generate(input_ids, **generator_args)
|
12 |
+
return tokenizer.batch_decode(res, skip_special_tokens=True)
|
|
|
|
|
|
|
|
|
|
|
|