Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,18 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
st.title("Paraphrase Generator")
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
if st.button("Generate Paraphrase"):
|
| 10 |
-
if
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
paraphrase =
|
| 14 |
st.markdown("**Paraphrase:**")
|
| 15 |
st.markdown(paraphrase)
|
| 16 |
else:
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Create a text2text-generation pipeline with the "google/flan-t5-base" model
|
| 5 |
+
paraphrase_generator = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 6 |
|
| 7 |
st.title("Paraphrase Generator")
|
| 8 |
+
|
| 9 |
+
user_input = st.text_input("Enter a line:")
|
| 10 |
|
| 11 |
if st.button("Generate Paraphrase"):
|
| 12 |
+
if user_input:
|
| 13 |
+
# Use a prompt to control the paraphrasing
|
| 14 |
+
paraphrase_prompt = f"Paraphrase the following line: '{user_input}'"
|
| 15 |
+
paraphrase = paraphrase_generator(paraphrase_prompt, max_length=100, do_sample=True)[0]["generated_text"]
|
| 16 |
st.markdown("**Paraphrase:**")
|
| 17 |
st.markdown(paraphrase)
|
| 18 |
else:
|