Update app.py
Browse files
app.py
CHANGED
|
@@ -4,15 +4,15 @@ from transformers import pipeline
|
|
| 4 |
# Create a text generation pipeline with the "gpt2" model
|
| 5 |
pipe = pipeline("text-generation", model="gpt2")
|
| 6 |
|
| 7 |
-
st.title("
|
| 8 |
user_word = st.text_input("Enter a word:")
|
| 9 |
|
| 10 |
if st.button("Generate Poem"):
|
| 11 |
if user_word:
|
| 12 |
-
# Prompt the model with a structured
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
st.markdown("**
|
| 16 |
-
st.markdown(
|
| 17 |
else:
|
| 18 |
st.warning("Please enter a word.")
|
|
|
|
| 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 word:")
|
| 9 |
|
| 10 |
if st.button("Generate Poem"):
|
| 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 word.")
|