Spaces:
Runtime error
Runtime error
Update converse.py
Browse files- converse.py +12 -9
converse.py
CHANGED
@@ -23,6 +23,8 @@ def discussion(
|
|
23 |
top_k=50,
|
24 |
temperature=0.7,
|
25 |
full_text=False,
|
|
|
|
|
26 |
num_return_sequences=1,
|
27 |
device=-1,
|
28 |
verbose=False,
|
@@ -73,6 +75,8 @@ def discussion(
|
|
73 |
top_k=top_k,
|
74 |
temperature=temperature,
|
75 |
full_text=full_text,
|
|
|
|
|
76 |
num_return_sequences=num_return_sequences,
|
77 |
device=device,
|
78 |
verbose=verbose,
|
@@ -106,13 +110,15 @@ def gen_response(
|
|
106 |
responder: str,
|
107 |
timeout=45,
|
108 |
min_length=4,
|
109 |
-
max_length=
|
110 |
top_p=0.95,
|
111 |
-
top_k=
|
112 |
-
temperature=0.
|
113 |
full_text=False,
|
114 |
num_return_sequences=1,
|
115 |
-
length_penalty=0.
|
|
|
|
|
116 |
device=-1,
|
117 |
verbose=False,
|
118 |
**kwargs,
|
@@ -158,8 +164,8 @@ def gen_response(
|
|
158 |
num_return_sequences=num_return_sequences,
|
159 |
max_time=timeout,
|
160 |
return_full_text=full_text,
|
161 |
-
no_repeat_ngram_size=
|
162 |
-
repetition_penalty=
|
163 |
length_penalty=length_penalty,
|
164 |
clean_up_tokenization_spaces=True,
|
165 |
remove_invalid_values=True,
|
@@ -168,7 +174,6 @@ def gen_response(
|
|
168 |
rt = round(time.perf_counter() - st, 2)
|
169 |
if verbose:
|
170 |
print(f"took {rt} sec to respond")
|
171 |
-
|
172 |
if verbose:
|
173 |
print("\n[DEBUG] generated:\n")
|
174 |
pp.pprint(response) # for debugging
|
@@ -186,7 +191,6 @@ def gen_response(
|
|
186 |
)
|
187 |
if verbose:
|
188 |
print(f"DEBUG: {bot_dialogue} was original response pre-SC")
|
189 |
-
|
190 |
return bot_dialogue #
|
191 |
|
192 |
|
@@ -251,5 +255,4 @@ def consolidate_texts(
|
|
251 |
print("\nthe full response is:\n")
|
252 |
print("\n".join(fn_resp))
|
253 |
print("--" * 10)
|
254 |
-
|
255 |
return fn_resp
|
|
|
23 |
top_k=50,
|
24 |
temperature=0.7,
|
25 |
full_text=False,
|
26 |
+
length_penalty=0.8,
|
27 |
+
no_repeat_ngram_size=2,
|
28 |
num_return_sequences=1,
|
29 |
device=-1,
|
30 |
verbose=False,
|
|
|
75 |
top_k=top_k,
|
76 |
temperature=temperature,
|
77 |
full_text=full_text,
|
78 |
+
no_repeat_ngram_size=no_repeat_ngram_size,
|
79 |
+
length_penalty=length_penalty,
|
80 |
num_return_sequences=num_return_sequences,
|
81 |
device=device,
|
82 |
verbose=verbose,
|
|
|
110 |
responder: str,
|
111 |
timeout=45,
|
112 |
min_length=4,
|
113 |
+
max_length=48,
|
114 |
top_p=0.95,
|
115 |
+
top_k=20,
|
116 |
+
temperature=0.5,
|
117 |
full_text=False,
|
118 |
num_return_sequences=1,
|
119 |
+
length_penalty:float=0.8,
|
120 |
+
repetition_penalty:float=3.5,
|
121 |
+
no_repeat_ngram_size=2,
|
122 |
device=-1,
|
123 |
verbose=False,
|
124 |
**kwargs,
|
|
|
164 |
num_return_sequences=num_return_sequences,
|
165 |
max_time=timeout,
|
166 |
return_full_text=full_text,
|
167 |
+
no_repeat_ngram_size=no_repeat_ngram_size,
|
168 |
+
repetition_penalty=repetition_penalty,
|
169 |
length_penalty=length_penalty,
|
170 |
clean_up_tokenization_spaces=True,
|
171 |
remove_invalid_values=True,
|
|
|
174 |
rt = round(time.perf_counter() - st, 2)
|
175 |
if verbose:
|
176 |
print(f"took {rt} sec to respond")
|
|
|
177 |
if verbose:
|
178 |
print("\n[DEBUG] generated:\n")
|
179 |
pp.pprint(response) # for debugging
|
|
|
191 |
)
|
192 |
if verbose:
|
193 |
print(f"DEBUG: {bot_dialogue} was original response pre-SC")
|
|
|
194 |
return bot_dialogue #
|
195 |
|
196 |
|
|
|
255 |
print("\nthe full response is:\n")
|
256 |
print("\n".join(fn_resp))
|
257 |
print("--" * 10)
|
|
|
258 |
return fn_resp
|