mkoot007 commited on
Commit
8e65c11
1 Parent(s): d9edb4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -1,16 +1,18 @@
1
  import streamlit as st
2
- from transformers import pipeline, set_seed
3
 
4
- pipe = pipeline("text-generation", model="google/flan-t5-base")
 
5
 
6
  st.title("Paraphrase Generator")
7
- user_word = st.text_input("Enter a line:")
 
8
 
9
  if st.button("Generate Paraphrase"):
10
- if user_word:
11
- paraphrase_prompt= f"Write a Paraphrase on '{user_word}'.\n"
12
- set_seed(42)
13
- paraphrase = pipe(paraphrase_prompt, max_length=100, do_sample=True, num_return_sequences=1)[0]["generated_text"]
14
  st.markdown("**Paraphrase:**")
15
  st.markdown(paraphrase)
16
  else:
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
 
4
+ # Create a text2text-generation pipeline with the "google/flan-t5-base" model
5
+ paraphrase_generator = pipeline("text2text-generation", model="google/flan-t5-base")
6
 
7
  st.title("Paraphrase Generator")
8
+
9
+ user_input = st.text_input("Enter a line:")
10
 
11
  if st.button("Generate Paraphrase"):
12
+ if user_input:
13
+ # Use a prompt to control the paraphrasing
14
+ paraphrase_prompt = f"Paraphrase the following line: '{user_input}'"
15
+ paraphrase = paraphrase_generator(paraphrase_prompt, max_length=100, do_sample=True)[0]["generated_text"]
16
  st.markdown("**Paraphrase:**")
17
  st.markdown(paraphrase)
18
  else: