File size: 674 Bytes
67448d5
f04691c
bc75555
d2bc37a
 
67448d5
8dbce5c
d2bc37a
bc75555
d2bc37a
 
8dbce5c
 
 
 
 
67448d5
d2bc37a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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.")