Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,12 @@ untethered_model = GPT2LMHeadModel.from_pretrained('zmbfeng/untethered_20240225_
|
|
13 |
untethered_paraphrased_model = GPT2LMHeadModel.from_pretrained('zmbfeng/untethered_20240227_epochs_350')
|
14 |
|
15 |
def create_response_untethered_paraphrased(input_str,
|
16 |
-
num_beams,
|
17 |
num_return_sequences,
|
18 |
temperature,
|
19 |
repetition_penalty,
|
20 |
top_p,
|
21 |
-
top_k,
|
22 |
do_sample):
|
23 |
print("input_str="+input_str)
|
24 |
num_beams = int(num_beams)
|
@@ -62,12 +62,12 @@ def create_response_untethered_paraphrased(input_str,
|
|
62 |
|
63 |
|
64 |
def create_response_untethered(input_str,
|
65 |
-
num_beams,
|
66 |
num_return_sequences,
|
67 |
temperature,
|
68 |
repetition_penalty,
|
69 |
top_p,
|
70 |
-
top_k,
|
71 |
do_sample):
|
72 |
print("input_str="+input_str)
|
73 |
num_beams = int(num_beams)
|
@@ -110,12 +110,12 @@ def create_response_untethered(input_str,
|
|
110 |
return outputs
|
111 |
|
112 |
def create_response_original(input_str,
|
113 |
-
num_beams,
|
114 |
num_return_sequences,
|
115 |
temperature,
|
116 |
repetition_penalty,
|
117 |
top_p,
|
118 |
-
top_k,
|
119 |
do_sample):
|
120 |
print("input_str="+input_str)
|
121 |
num_beams = int(num_beams)
|
@@ -171,15 +171,15 @@ interface1 = gr.Interface(fn=create_response_original,
|
|
171 |
title="original",
|
172 |
description="original language model, no fine tuning",
|
173 |
examples=[
|
174 |
-
["What is death?",
|
175 |
-
["One of the best teachers in all of life turns out to be what?",
|
176 |
-
["what is your most meaningful relationship?",
|
177 |
-
["What actually gives life meaning?",
|
178 |
],
|
179 |
inputs=[
|
180 |
gr.Textbox(label="input text here", lines=3),
|
181 |
-
gr.Number(label="num_beams (integer) explores the specified number of possible outputs and selects the most " +
|
182 |
-
|
183 |
gr.Number(label="num_return_sequences (integer) the number of outputs selected from num_beams possible output",
|
184 |
value=5),
|
185 |
gr.Number(
|
@@ -194,11 +194,11 @@ interface1 = gr.Interface(fn=create_response_original,
|
|
194 |
gr.Number(label="top_p (decimal) the model will only consider the words that have a high enough probability" +
|
195 |
" to reach a certain threshold",
|
196 |
value=0.9),
|
197 |
-
gr.Number(label="top_k (integer) The number of highest probability vocabulary word will be considered" +
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
gr.Checkbox(label="do_sample. If is set to False, num_return_sequences must be 1 because the generate function will use greedy decoding, " +
|
203 |
"which means that it will select the word with the highest probability at each step. " +
|
204 |
"This results in a deterministic and fluent output, but it might also lack diversity and creativity" +
|
@@ -212,15 +212,15 @@ interface2 = gr.Interface(fn=create_response_untethered,
|
|
212 |
title="untethered",
|
213 |
description="untethered fine tuning",
|
214 |
examples=[
|
215 |
-
["What is death?",
|
216 |
-
["One of the best teachers in all of life turns out to be what?",
|
217 |
-
["what is your most meaningful relationship?",
|
218 |
-
["What actually gives life meaning?",
|
219 |
],
|
220 |
inputs=[
|
221 |
gr.Textbox(label="input text here", lines=3),
|
222 |
-
gr.Number(label="num_beams (integer) explores the specified number of possible outputs and selects the most " +
|
223 |
-
|
224 |
gr.Number(label="num_return_sequences (integer) the number of outputs selected from num_beams possible output",
|
225 |
value=5),
|
226 |
gr.Number(
|
@@ -235,11 +235,11 @@ interface2 = gr.Interface(fn=create_response_untethered,
|
|
235 |
gr.Number(label="top_p (decimal) the model will only consider the words that have a high enough probability" +
|
236 |
" to reach a certain threshold",
|
237 |
value=0.9),
|
238 |
-
gr.Number(label="top_k (integer) The number of highest probability vocabulary word will be considered" +
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
gr.Checkbox(label="do_sample. If is set to False, num_return_sequences must be 1 because the generate function will use greedy decoding, " +
|
244 |
"which means that it will select the word with the highest probability at each step. " +
|
245 |
"This results in a deterministic and fluent output, but it might also lack diversity and creativity" +
|
@@ -252,15 +252,15 @@ interface3 = gr.Interface(fn=create_response_untethered_paraphrased,
|
|
252 |
title="untethered paraphrased",
|
253 |
description="untethered paraphrased fine tuning",
|
254 |
examples=[
|
255 |
-
["What is death?",
|
256 |
-
["One of the best teachers in all of life turns out to be what?",
|
257 |
-
["what is your most meaningful relationship?",
|
258 |
-
["What actually gives life meaning?",
|
259 |
],
|
260 |
inputs=[
|
261 |
gr.Textbox(label="input text here", lines=3),
|
262 |
-
gr.Number(label="num_beams (integer) explores the specified number of possible outputs and selects the most " +
|
263 |
-
|
264 |
gr.Number(label="num_return_sequences (integer) the number of outputs selected from num_beams possible output",
|
265 |
value=5),
|
266 |
gr.Number(
|
@@ -275,11 +275,11 @@ interface3 = gr.Interface(fn=create_response_untethered_paraphrased,
|
|
275 |
gr.Number(label="top_p (decimal) the model will only consider the words that have a high enough probability" +
|
276 |
" to reach a certain threshold",
|
277 |
value=0.9),
|
278 |
-
gr.Number(label="top_k (integer) The number of highest probability vocabulary word will be considered" +
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
gr.Checkbox(label="do_sample. If is set to False, num_return_sequences must be 1 because the generate function will use greedy decoding, " +
|
284 |
"which means that it will select the word with the highest probability at each step. " +
|
285 |
"This results in a deterministic and fluent output, but it might also lack diversity and creativity" +
|
|
|
13 |
untethered_paraphrased_model = GPT2LMHeadModel.from_pretrained('zmbfeng/untethered_20240227_epochs_350')
|
14 |
|
15 |
def create_response_untethered_paraphrased(input_str,
|
16 |
+
# num_beams,
|
17 |
num_return_sequences,
|
18 |
temperature,
|
19 |
repetition_penalty,
|
20 |
top_p,
|
21 |
+
# top_k,
|
22 |
do_sample):
|
23 |
print("input_str="+input_str)
|
24 |
num_beams = int(num_beams)
|
|
|
62 |
|
63 |
|
64 |
def create_response_untethered(input_str,
|
65 |
+
# num_beams,
|
66 |
num_return_sequences,
|
67 |
temperature,
|
68 |
repetition_penalty,
|
69 |
top_p,
|
70 |
+
# top_k,
|
71 |
do_sample):
|
72 |
print("input_str="+input_str)
|
73 |
num_beams = int(num_beams)
|
|
|
110 |
return outputs
|
111 |
|
112 |
def create_response_original(input_str,
|
113 |
+
# num_beams,
|
114 |
num_return_sequences,
|
115 |
temperature,
|
116 |
repetition_penalty,
|
117 |
top_p,
|
118 |
+
# top_k,
|
119 |
do_sample):
|
120 |
print("input_str="+input_str)
|
121 |
num_beams = int(num_beams)
|
|
|
171 |
title="original",
|
172 |
description="original language model, no fine tuning",
|
173 |
examples=[
|
174 |
+
["What is death?",5,0.2,1.5,0.9,True], # The first example
|
175 |
+
["One of the best teachers in all of life turns out to be what?",5,0.2,1.5,0.9,True], # The second example
|
176 |
+
["what is your most meaningful relationship?",5,0.2,1.5,0.9,True], # The third example
|
177 |
+
["What actually gives life meaning?",5,0.2,1.5,0.9,True]
|
178 |
],
|
179 |
inputs=[
|
180 |
gr.Textbox(label="input text here", lines=3),
|
181 |
+
# gr.Number(label="num_beams (integer) explores the specified number of possible outputs and selects the most " +
|
182 |
+
# "likely ones (specified in num_beams)", value=7),
|
183 |
gr.Number(label="num_return_sequences (integer) the number of outputs selected from num_beams possible output",
|
184 |
value=5),
|
185 |
gr.Number(
|
|
|
194 |
gr.Number(label="top_p (decimal) the model will only consider the words that have a high enough probability" +
|
195 |
" to reach a certain threshold",
|
196 |
value=0.9),
|
197 |
+
# gr.Number(label="top_k (integer) The number of highest probability vocabulary word will be considered" +
|
198 |
+
# "This means that only the tokens with the highest probabilities are considered for sampling" +
|
199 |
+
# "This reduces the diversity of the generated sequences, "+
|
200 |
+
# "but also makes them more likely to be coherent and fluent.",
|
201 |
+
# value=50),
|
202 |
gr.Checkbox(label="do_sample. If is set to False, num_return_sequences must be 1 because the generate function will use greedy decoding, " +
|
203 |
"which means that it will select the word with the highest probability at each step. " +
|
204 |
"This results in a deterministic and fluent output, but it might also lack diversity and creativity" +
|
|
|
212 |
title="untethered",
|
213 |
description="untethered fine tuning",
|
214 |
examples=[
|
215 |
+
["What is death?",5,0.2,1.5,0.9,True], # The first example
|
216 |
+
["One of the best teachers in all of life turns out to be what?",5,0.2,1.5,0.9,True], # The second example
|
217 |
+
["what is your most meaningful relationship?",5,0.2,1.5,0.9,True], # The third example
|
218 |
+
["What actually gives life meaning?",5,0.2,1.5,0.9,True]
|
219 |
],
|
220 |
inputs=[
|
221 |
gr.Textbox(label="input text here", lines=3),
|
222 |
+
# gr.Number(label="num_beams (integer) explores the specified number of possible outputs and selects the most " +
|
223 |
+
# "likely ones (specified in num_beams)", value=7),
|
224 |
gr.Number(label="num_return_sequences (integer) the number of outputs selected from num_beams possible output",
|
225 |
value=5),
|
226 |
gr.Number(
|
|
|
235 |
gr.Number(label="top_p (decimal) the model will only consider the words that have a high enough probability" +
|
236 |
" to reach a certain threshold",
|
237 |
value=0.9),
|
238 |
+
# gr.Number(label="top_k (integer) The number of highest probability vocabulary word will be considered" +
|
239 |
+
# "This means that only the tokens with the highest probabilities are considered for sampling" +
|
240 |
+
# "This reduces the diversity of the generated sequences, "+
|
241 |
+
# "but also makes them more likely to be coherent and fluent.",
|
242 |
+
# value=50),
|
243 |
gr.Checkbox(label="do_sample. If is set to False, num_return_sequences must be 1 because the generate function will use greedy decoding, " +
|
244 |
"which means that it will select the word with the highest probability at each step. " +
|
245 |
"This results in a deterministic and fluent output, but it might also lack diversity and creativity" +
|
|
|
252 |
title="untethered paraphrased",
|
253 |
description="untethered paraphrased fine tuning",
|
254 |
examples=[
|
255 |
+
["What is death?",5,0.2,1.5,0.9,True], # The first example
|
256 |
+
["One of the best teachers in all of life turns out to be what?",5,0.2,1.5,0.9,True], # The second example
|
257 |
+
["what is your most meaningful relationship?",5,0.2,1.5,0.9,True], # The third example
|
258 |
+
["What actually gives life meaning?",5,0.2,1.5,0.9,True]
|
259 |
],
|
260 |
inputs=[
|
261 |
gr.Textbox(label="input text here", lines=3),
|
262 |
+
# gr.Number(label="num_beams (integer) explores the specified number of possible outputs and selects the most " +
|
263 |
+
# "likely ones (specified in num_beams)", value=7),
|
264 |
gr.Number(label="num_return_sequences (integer) the number of outputs selected from num_beams possible output",
|
265 |
value=5),
|
266 |
gr.Number(
|
|
|
275 |
gr.Number(label="top_p (decimal) the model will only consider the words that have a high enough probability" +
|
276 |
" to reach a certain threshold",
|
277 |
value=0.9),
|
278 |
+
# gr.Number(label="top_k (integer) The number of highest probability vocabulary word will be considered" +
|
279 |
+
# "This means that only the tokens with the highest probabilities are considered for sampling" +
|
280 |
+
# "This reduces the diversity of the generated sequences, "+
|
281 |
+
# "but also makes them more likely to be coherent and fluent.",
|
282 |
+
# value=50),
|
283 |
gr.Checkbox(label="do_sample. If is set to False, num_return_sequences must be 1 because the generate function will use greedy decoding, " +
|
284 |
"which means that it will select the word with the highest probability at each step. " +
|
285 |
"This results in a deterministic and fluent output, but it might also lack diversity and creativity" +
|