Yoxas commited on
Commit
57eb8dd
·
verified ·
1 Parent(s): 0c0b519

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
 
3
 
4
  # Load the tokenizer and model
5
  tokenizer = AutoTokenizer.from_pretrained("Yoxas/autotrain-phi3-statistical", trust_remote_code=True)
@@ -9,6 +10,7 @@ model = AutoModelForCausalLM.from_pretrained("Yoxas/autotrain-phi3-statistical",
9
  pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, trust_remote_code=True)
10
 
11
  # Define the chatbot function
 
12
  def chatbot(input_text):
13
  response = pipe(input_text, max_length=150, num_return_sequences=1)
14
  return response[0]['generated_text']
 
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
+ import spaces
4
 
5
  # Load the tokenizer and model
6
  tokenizer = AutoTokenizer.from_pretrained("Yoxas/autotrain-phi3-statistical", trust_remote_code=True)
 
10
  pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, trust_remote_code=True)
11
 
12
  # Define the chatbot function
13
+ @spaces.GPU(duration=120)
14
  def chatbot(input_text):
15
  response = pipe(input_text, max_length=150, num_return_sequences=1)
16
  return response[0]['generated_text']