mudogruer commited on
Commit
3998848
·
verified ·
1 Parent(s): 617afda

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -46,6 +46,8 @@ phi2 = pipeline(
46
  device_map="cpu",
47
  )
48
 
 
 
49
  def generate(message, max_new_tokens):
50
  instruction = "You are a helpful assistant to 'User'. You do not respond as 'User' or pretend to be 'User'. You only respond once as 'Assistant'."
51
  final_prompt = f"Instruction: {instruction}\nUser: {message}\nOutput:"
@@ -61,7 +63,7 @@ def generate(message, max_new_tokens):
61
 
62
  # Update the Gradio interface setup
63
  with gr.Blocks() as demo:
64
- gr.Markdown("""### Phi-2 Scientific Question Chatbot""")
65
  tokens_slider = gr.Slider(8, 128, value=21, label="Maximum new tokens")
66
- chatbot = gr.Interface(fn=generate, inputs=["text", tokens_slider], outputs="text")
67
- demo.launch()
 
46
  device_map="cpu",
47
  )
48
 
49
+ examples = ["Which organelle carries out the synthesis and packaging of digestive enzymes?", "What is the change in speed of a moving object per unit time?" ,"What is the formula of carbon tetrafluoride?"]
50
+
51
  def generate(message, max_new_tokens):
52
  instruction = "You are a helpful assistant to 'User'. You do not respond as 'User' or pretend to be 'User'. You only respond once as 'Assistant'."
53
  final_prompt = f"Instruction: {instruction}\nUser: {message}\nOutput:"
 
63
 
64
  # Update the Gradio interface setup
65
  with gr.Blocks() as demo:
66
+ gr.Markdown("""### Phi-2 Scientific Question Chatbot(Fine-tuned from SciQ dataset)""")
67
  tokens_slider = gr.Slider(8, 128, value=21, label="Maximum new tokens")
68
+ chatbot = gr.Interface(fn=generate, inputs=["text", tokens_slider], outputs="text", examples = examples)
69
+ demo.launch(share=True)