SudhanshuBlaze commited on
Commit
cbcc475
·
1 Parent(s): 6b66e49

add code in app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py CHANGED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ st.title("AI text-gen Web-app")
5
+ st.write("This is auto-complete/text generation a web-app powered by GPT-neo. GPT-Neo 125M is a transformer model designed using EleutherAI's replication of the GPT-3 architecture. GPT-Neo refers to the class of models, while 125M represents the number of parameters of this particular pre-trained model.")
6
+
7
+ # instantiate the model / download
8
+ generator = pipeline('text-generation', model='EleutherAI/gpt-neo-125M')
9
+
10
+ min_length=st.slider(
11
+ 'Specify Min length of the text of want to be generated',
12
+ 10, 100, 25)
13
+ max_length=st.slider(
14
+ 'Specify Max length of the text of want to be generated',
15
+ 20, 150, 50)
16
+
17
+ # create a prompt text for the text generation
18
+ prompt_text = st.text_input(
19
+ label = "Enter your prompt text...",
20
+ value="We live in a society")
21
+
22
+
23
+ if(max_length<=min_length):
24
+ st.error("max_length cannot be less than equal to min_length")
25
+ else:
26
+ with st.spinner("AI is at Work........"):
27
+ gpt_text = generator(
28
+ prompt_text,
29
+ min_length=min_length,
30
+ max_length=max_length,
31
+ do_sample=True)[0]["generated_text"]
32
+ st.success("GPT neo Successfully generated the below text ")
33
+ st.balloons()
34
+ st.write(gpt_text)