s3nh commited on
Commit
4679d7b
·
1 Parent(s): a73f1df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -30
app.py CHANGED
@@ -63,40 +63,35 @@ def evaluate(instruction, input=None):
63
  result.append( output.split("### Response:")[1].strip())
64
  return ' '.join(el for el in result)
65
 
66
- def inference(text, input):
 
 
67
  output = evaluate(instruction = text, input = input)
68
  return output
69
 
70
  def choose_model(name):
71
  return load_model(name), load_tokenizer(name)
72
 
73
- demo = gr.Blocks()
74
-
75
- with demo:
76
-
77
-
78
- name = gr.Dropdown(["s3nh/pythia-1.4b-deduped-16k-steps-self-instruct-polish", "s3nh/pythia-410m-91k-steps-self-instruct-polish"])
79
- model = load_model(name)
80
- tokenizer = load_tokenizer(name)
81
-
82
- io = gr.Interface(
83
- inference,
84
- inputs = [gr.Textbox(
85
- lines = 3,
86
- max_lines = 10,
87
- placeholder = "Add question here",
88
- interactive = True,
89
- show_label = False
90
- ),
91
- gr.Textbox(
92
- lines = 3,
93
- max_lines = 10,
94
- placeholder = "Add context here",
95
- interactive = True,
96
- show_label = False
97
- )],
98
- outputs = [gr.Textbox(lines = 1, label = 'Pythia410m', interactive = False)],
99
- cache_examples = False,
100
- )
101
 
102
- demo.launch(debug = True)
 
63
  result.append( output.split("### Response:")[1].strip())
64
  return ' '.join(el for el in result)
65
 
66
+ def inference(model_name, text, input):
67
+ model = load_model(model_name)
68
+ tokenizer = load_tokenizer(model_name)
69
  output = evaluate(instruction = text, input = input)
70
  return output
71
 
72
  def choose_model(name):
73
  return load_model(name), load_tokenizer(name)
74
 
75
+ io = gr.Interface(
76
+ inference,
77
+ inputs = [
78
+ gr.Dropdown(["s3nh/pythia-1.4b-deduped-16k-steps-self-instruct-polish", "s3nh/pythia-410m-91k-steps-self-instruct-polish"]),
79
+ gr.Textbox(
80
+ lines = 3,
81
+ max_lines = 10,
82
+ placeholder = "Add question here",
83
+ interactive = True,
84
+ show_label = False
85
+ ),
86
+ gr.Textbox(
87
+ lines = 3,
88
+ max_lines = 10,
89
+ placeholder = "Add context here",
90
+ interactive = True,
91
+ show_label = False
92
+ )],
93
+ outputs = [gr.Textbox(lines = 1, label = 'Pythia410m', interactive = False)],
94
+ cache_examples = False,
95
+ )
 
 
 
 
 
 
 
96
 
97
+ io.launch(debug = True)