Text2Text / app.py
mkoot007's picture
Update app.py
e09c460
raw
history blame
655 Bytes
import streamlit as st
from transformers import pipeline, set_seed
pipe = pipeline("text-generation", model="gpt2")
st.title("Paraphrase Generator")
user_word = st.text_input("Enter a line:")
if st.button("Generate Paraphrase"):
if user_word:
# Prompt the model with a structured paraphrase request
paraphrase_prompt= f"Write a Paraphrase about '{user_word}'.\n"
# set_seed(42)
paraphrase = pipe(paraphrase_prompt, max_length=200, do_sample=True, num_return_sequences=1)[0]["generated_text"]
st.markdown("**Paraphrase:**")
st.markdown(paraphrase)
else:
st.warning("Please enter a line.")