hereoncollab commited on
Commit
b6144f6
·
verified ·
1 Parent(s): ce385fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -1,19 +1,23 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Use a smaller model for lower memory usage
5
- pipe = pipeline("text-generation", model="distilgpt2") # DistilGPT-2 is smaller and more efficient
6
 
7
- def generate_response(prompt):
8
- responses = pipe(prompt, max_length=50, num_return_sequences=1)
9
- return responses[0]['generated_text']
 
 
 
 
 
 
10
 
11
  interface = gr.Interface(
12
  fn=generate_response,
13
- inputs=gr.Textbox(label="Enter your message:", lines=2, placeholder="Type your message here..."),
14
  outputs="text",
15
- title="Smaller Model Chatbot",
16
- description="A chatbot using a smaller model for lower memory usage."
17
  )
18
 
19
  interface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
 
4
 
5
+ pipe = pipeline("text-generation", model="distilgpt2")
6
+
7
+ def generate_response(user_input):
8
+ formatted_input = f"Human: {user_input}\nAI:"
9
+ response = pipe(formatted_input, max_length=150, num_return_sequences=1)
10
+ generated_text = response[0]['generated_text']
11
+ ai_response = generated_text.split('AI:')[-1].strip()
12
+ return ai_response
13
+
14
 
15
  interface = gr.Interface(
16
  fn=generate_response,
17
+ inputs=gr.Textbox(label="shitty mesage:", lines=2, placeholder="Type your message here..."),
18
  outputs="text",
19
+ title="distilgpt2",
20
+ description="distel gppt 20"
21
  )
22
 
23
  interface.launch()