Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,19 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
# Create a text generation pipeline with the "gpt2" model
|
| 5 |
pipe = pipeline("text-generation", model="gpt2")
|
| 6 |
|
| 7 |
st.title("Paraphrase Generator")
|
| 8 |
-
user_word = st.text_input("Enter a
|
| 9 |
|
| 10 |
-
if st.button("Generate
|
| 11 |
if user_word:
|
| 12 |
# Prompt the model with a structured paraphrase request
|
| 13 |
paraphrase_prompt= f"Write a Paraphrase about '{user_word}'.\n"
|
|
|
|
| 14 |
paraphrase = pipe(paraphrase_prompt, max_length=200, do_sample=True, num_return_sequences=1)[0]["generated_text"]
|
| 15 |
st.markdown("**Paraphrase:**")
|
| 16 |
st.markdown(paraphrase)
|
| 17 |
else:
|
| 18 |
-
st.warning("Please enter a
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import pipeline, set_seed
|
| 3 |
|
| 4 |
# Create a text generation pipeline with the "gpt2" model
|
| 5 |
pipe = pipeline("text-generation", model="gpt2")
|
| 6 |
|
| 7 |
st.title("Paraphrase Generator")
|
| 8 |
+
user_word = st.text_input("Enter a line:")
|
| 9 |
|
| 10 |
+
if st.button("Generate Paraphrase"):
|
| 11 |
if user_word:
|
| 12 |
# Prompt the model with a structured paraphrase request
|
| 13 |
paraphrase_prompt= f"Write a Paraphrase about '{user_word}'.\n"
|
| 14 |
+
set_seed(42)
|
| 15 |
paraphrase = pipe(paraphrase_prompt, max_length=200, do_sample=True, num_return_sequences=1)[0]["generated_text"]
|
| 16 |
st.markdown("**Paraphrase:**")
|
| 17 |
st.markdown(paraphrase)
|
| 18 |
else:
|
| 19 |
+
st.warning("Please enter a line.")
|