mkoot007 commited on
Commit
6372def
1 Parent(s): 8dbce5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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 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.")
 
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.")