Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wuxk1
Megatron-LM
Commits
8d405805
Commit
8d405805
authored
Oct 14, 2021
by
rprenger
Browse files
Changing defaults and query sanitation to keep it from crashing on reasonable queries
parent
0dd5cc75
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
megatron/text_generation_server.py
megatron/text_generation_server.py
+5
-4
No files found.
megatron/text_generation_server.py
View file @
8d405805
...
...
@@ -19,7 +19,6 @@ import threading
from
flask
import
Flask
,
request
,
jsonify
,
current_app
from
flask_restful
import
Resource
,
Api
from
megatron
import
get_args
from
megatron
import
mpu
from
megatron.text_generation
import
generate_and_post_process
...
...
@@ -68,7 +67,7 @@ class MegatronGenerate(Resource):
if
not
isinstance
(
logprobs
,
bool
):
return
"logprobs must be a boolean value"
temperature
=
args
.
temperature
temperature
=
1.0
if
"temperature"
in
request
.
get_json
():
temperature
=
request
.
get_json
()[
"temperature"
]
if
not
(
type
(
temperature
)
==
int
or
type
(
temperature
)
==
float
):
...
...
@@ -76,7 +75,7 @@ class MegatronGenerate(Resource):
if
not
(
0.0
<
temperature
<=
100.0
):
return
"temperature must be a positive number less than or equal to 100.0"
top_k
=
args
.
top_k
top_k
=
0.0
if
"top_k"
in
request
.
get_json
():
top_k
=
request
.
get_json
()[
"top_k"
]
if
not
(
type
(
top_k
)
==
int
):
...
...
@@ -84,11 +83,13 @@ class MegatronGenerate(Resource):
if
not
(
0
<
top_k
<=
1000
):
return
"top_k must be equal to or greater than 0 and less than or equal to 1000"
top_p
=
args
.
top_p
top_p
=
0.0
if
"top_p"
in
request
.
get_json
():
top_p
=
request
.
get_json
()[
"top_p"
]
if
not
(
type
(
top_p
)
==
float
):
return
"top_p must be a positive float less than or equal to 1.0"
if
top_p
>
0.0
and
top_k
>
0.0
:
return
"cannot set both top-k and top-p samplings."
if
not
(
0
<
top_p
<=
1.0
):
return
"top_p must be less than or equal to 1.0"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment