Spaces:
Runtime error
Runtime error
Mel Nguyen (she/her)
commited on
Commit
•
8529353
1
Parent(s):
04e7e8d
add button
Browse files
app.py
CHANGED
@@ -36,12 +36,13 @@ max_length = st.sidebar.slider("Max Length", min_value = 10, max_value=500)
|
|
36 |
#top_k = st.sidebar.slider("Top-k", min_value = 0, max_value=5, value = 0)
|
37 |
#top_p = st.sidebar.slider("Top-p", min_value = 0.0, max_value=1.0, step = 0.05, value = 0.9)
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
36 |
#top_k = st.sidebar.slider("Top-k", min_value = 0, max_value=5, value = 0)
|
37 |
#top_p = st.sidebar.slider("Top-p", min_value = 0.0, max_value=1.0, step = 0.05, value = 0.9)
|
38 |
|
39 |
+
if st.button("Generate Text"):
|
40 |
+
encoded_prompt = tokenizer.encode(sent, add_special_tokens=False, return_tensors="pt")
|
41 |
+
if encoded_prompt.size()[-1] == 0:
|
42 |
+
input_ids = None
|
43 |
+
else:
|
44 |
+
input_ids = encoded_prompt
|
45 |
+
|
46 |
+
gen_tokens = infer(encoded_prompt, max_length)
|
47 |
+
gen_text = tokenizer.batch_decode(gen_tokens)[0]
|
48 |
+
st.write(gen_text)
|