import streamlit as st | |
from transformers import pipeline | |
# Create a text generation pipeline with the "gpt2" model | |
pipe = pipeline("text-generation", model="gpt2") | |
st.title("Paraphrase Generator") | |
user_word = st.text_input("Enter a word:") | |
if st.button("Generate Poem"): | |
if user_word: | |
# Prompt the model with a structured paraphrase request | |
paraphrase_prompt= f"Write a Paraphrase about '{user_word}'.\n" | |
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 word.") | |