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
OpenDAS
Megatron-LM
Commits
ed6806ac
Commit
ed6806ac
authored
Jun 21, 2022
by
rprenger
Browse files
Changing name of parameters from factual_decay to top_p_decay
parent
b49349ec
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
34 deletions
+34
-34
megatron/text_generation/api.py
megatron/text_generation/api.py
+11
-11
megatron/text_generation/generation.py
megatron/text_generation/generation.py
+5
-5
megatron/text_generation_server.py
megatron/text_generation_server.py
+18
-18
No files found.
megatron/text_generation/api.py
View file @
ed6806ac
...
@@ -33,8 +33,8 @@ def generate_and_post_process(model,
...
@@ -33,8 +33,8 @@ def generate_and_post_process(model,
return_output_log_probs
=
False
,
return_output_log_probs
=
False
,
top_k_sampling
=
0
,
top_k_sampling
=
0
,
top_p_sampling
=
0.0
,
top_p_sampling
=
0.0
,
factual
_decay
=
0.0
,
top_p
_decay
=
0.0
,
factual
_bound
=
0.0
,
top_p
_bound
=
0.0
,
temperature
=
1.0
,
temperature
=
1.0
,
add_BOS
=
False
,
add_BOS
=
False
,
use_eod_token_for_early_termination
=
True
,
use_eod_token_for_early_termination
=
True
,
...
@@ -52,8 +52,8 @@ def generate_and_post_process(model,
...
@@ -52,8 +52,8 @@ def generate_and_post_process(model,
return_output_log_probs
=
return_output_log_probs
,
return_output_log_probs
=
return_output_log_probs
,
top_k_sampling
=
top_k_sampling
,
top_k_sampling
=
top_k_sampling
,
top_p_sampling
=
top_p_sampling
,
top_p_sampling
=
top_p_sampling
,
factual_decay
=
factual
_decay
,
top_p_decay
=
top_p
_decay
,
factual_bound
=
factual
_bound
,
top_p_bound
=
top_p
_bound
,
temperature
=
temperature
,
temperature
=
temperature
,
add_BOS
=
add_BOS
,
add_BOS
=
add_BOS
,
use_eod_token_for_early_termination
=
use_eod_token_for_early_termination
,
use_eod_token_for_early_termination
=
use_eod_token_for_early_termination
,
...
@@ -82,8 +82,8 @@ def generate(model,
...
@@ -82,8 +82,8 @@ def generate(model,
return_output_log_probs
=
False
,
return_output_log_probs
=
False
,
top_k_sampling
=
0
,
top_k_sampling
=
0
,
top_p_sampling
=
0.0
,
top_p_sampling
=
0.0
,
factual
_decay
=
0.0
,
top_p
_decay
=
0.0
,
factual
_bound
=
0.0
,
top_p
_bound
=
0.0
,
temperature
=
1.0
,
temperature
=
1.0
,
add_BOS
=
False
,
add_BOS
=
False
,
use_eod_token_for_early_termination
=
True
,
use_eod_token_for_early_termination
=
True
,
...
@@ -101,7 +101,7 @@ def generate(model,
...
@@ -101,7 +101,7 @@ def generate(model,
# Make sure input params are avaialble to all ranks.
# Make sure input params are avaialble to all ranks.
values
=
[
tokens_to_generate
,
values
=
[
tokens_to_generate
,
return_output_log_probs
,
return_output_log_probs
,
top_k_sampling
,
top_p_sampling
,
factual
_decay
,
factual
_bound
,
top_k_sampling
,
top_p_sampling
,
top_p
_decay
,
top_p
_bound
,
temperature
,
add_BOS
,
use_eod_token_for_early_termination
,
temperature
,
add_BOS
,
use_eod_token_for_early_termination
,
stop_on_double_eol
,
stop_on_double_eol
,
stop_on_eol
,
stop_on_eol
,
...
@@ -111,8 +111,8 @@ def generate(model,
...
@@ -111,8 +111,8 @@ def generate(model,
return_output_log_probs
=
bool
(
values_float_tensor
[
1
].
item
())
return_output_log_probs
=
bool
(
values_float_tensor
[
1
].
item
())
top_k_sampling
=
int
(
values_float_tensor
[
2
].
item
())
top_k_sampling
=
int
(
values_float_tensor
[
2
].
item
())
top_p_sampling
=
values_float_tensor
[
3
].
item
()
top_p_sampling
=
values_float_tensor
[
3
].
item
()
factual
_decay
=
values_float_tensor
[
4
].
item
()
top_p
_decay
=
values_float_tensor
[
4
].
item
()
factual
_bound
=
values_float_tensor
[
5
].
item
()
top_p
_bound
=
values_float_tensor
[
5
].
item
()
temperature
=
values_float_tensor
[
6
].
item
()
temperature
=
values_float_tensor
[
6
].
item
()
add_BOS
=
bool
(
values_float_tensor
[
7
].
item
())
add_BOS
=
bool
(
values_float_tensor
[
7
].
item
())
use_eod_token_for_early_termination
=
bool
(
values_float_tensor
[
8
].
item
())
use_eod_token_for_early_termination
=
bool
(
values_float_tensor
[
8
].
item
())
...
@@ -142,8 +142,8 @@ def generate(model,
...
@@ -142,8 +142,8 @@ def generate(model,
return_output_log_probs
=
return_output_log_probs
,
return_output_log_probs
=
return_output_log_probs
,
top_k
=
top_k_sampling
,
top_k
=
top_k_sampling
,
top_p
=
top_p_sampling
,
top_p
=
top_p_sampling
,
factual_decay
=
factual
_decay
,
top_p_decay
=
top_p
_decay
,
factual_bound
=
factual
_bound
,
top_p_bound
=
top_p
_bound
,
temperature
=
temperature
,
temperature
=
temperature
,
use_eod_token_for_early_termination
=
use_eod_token_for_early_termination
,
use_eod_token_for_early_termination
=
use_eod_token_for_early_termination
,
stop_on_double_eol
=
stop_on_double_eol
,
stop_on_double_eol
=
stop_on_double_eol
,
...
...
megatron/text_generation/generation.py
View file @
ed6806ac
...
@@ -94,7 +94,7 @@ def score_and_return_on_first_stage(model, tokens, lengths):
...
@@ -94,7 +94,7 @@ def score_and_return_on_first_stage(model, tokens, lengths):
def
generate_tokens_probs_and_return_on_first_stage
(
def
generate_tokens_probs_and_return_on_first_stage
(
model
,
tokens
,
lengths
,
model
,
tokens
,
lengths
,
return_output_log_probs
=
False
,
return_output_log_probs
=
False
,
top_k
=
0
,
top_p
=
0.0
,
factual
_decay
=
0.0
,
factual
_bound
=
0.0
,
top_k
=
0
,
top_p
=
0.0
,
top_p
_decay
=
0.0
,
top_p
_bound
=
0.0
,
temperature
=
1.0
,
temperature
=
1.0
,
use_eod_token_for_early_termination
=
True
,
use_eod_token_for_early_termination
=
True
,
stop_on_double_eol
=
False
,
stop_on_double_eol
=
False
,
...
@@ -200,10 +200,10 @@ def generate_tokens_probs_and_return_on_first_stage(
...
@@ -200,10 +200,10 @@ def generate_tokens_probs_and_return_on_first_stage(
top_p
=
top_p
,
top_p
=
top_p
,
temperature
=
temperature
,
temperature
=
temperature
,
vocab_size
=
tokenizer
.
vocab_size
)
vocab_size
=
tokenizer
.
vocab_size
)
if
top_p
>
0.0
and
factual
_decay
>
0.0
:
if
top_p
>
0.0
and
top_p
_decay
>
0.0
:
top_p
=
top_p
*
factual
_decay
top_p
=
top_p
*
top_p
_decay
if
factual
_bound
>
0.0
:
if
top_p
_bound
>
0.0
:
top_p
=
max
(
top_p
,
factual
_bound
)
top_p
=
max
(
top_p
,
top_p
_bound
)
# If a prompt length is smaller or equal th current context
# If a prompt length is smaller or equal th current context
# length, it means we have started generating tokens
# length, it means we have started generating tokens
...
...
megatron/text_generation_server.py
View file @
ed6806ac
...
@@ -93,25 +93,25 @@ class MegatronGenerate(Resource):
...
@@ -93,25 +93,25 @@ class MegatronGenerate(Resource):
if
not
(
0
<=
top_p
<=
1.0
):
if
not
(
0
<=
top_p
<=
1.0
):
return
"top_p must be less than or equal to 1.0"
return
"top_p must be less than or equal to 1.0"
factual
_decay
=
0.0
top_p
_decay
=
0.0
if
"
factual
_decay"
in
request
.
get_json
():
if
"
top_p
_decay"
in
request
.
get_json
():
factual
_decay
=
request
.
get_json
()[
"
factual
_decay"
]
top_p
_decay
=
request
.
get_json
()[
"
top_p
_decay"
]
if
not
(
type
(
factual
_decay
)
==
float
):
if
not
(
type
(
top_p
_decay
)
==
float
):
return
"
factual
_decay must be a positive float less than or equal to 1.0"
return
"
top_p
_decay must be a positive float less than or equal to 1.0"
if
top_p
==
0.0
:
if
top_p
==
0.0
:
return
"
factual
_decay cannot be set without top_p"
return
"
top_p
_decay cannot be set without top_p"
if
not
(
0
<=
factual
_decay
<=
1.0
):
if
not
(
0
<=
top_p
_decay
<=
1.0
):
return
"
factual
_decay must be less than or equal to 1.0"
return
"
top_p
_decay must be less than or equal to 1.0"
factual
_bound
=
0.0
top_p
_bound
=
0.0
if
"
factual
_bound"
in
request
.
get_json
():
if
"
top_p
_bound"
in
request
.
get_json
():
factual
_bound
=
request
.
get_json
()[
"
factual
_bound"
]
top_p
_bound
=
request
.
get_json
()[
"
top_p
_bound"
]
if
not
(
type
(
factual
_bound
)
==
float
):
if
not
(
type
(
top_p
_bound
)
==
float
):
return
"
factual
_bound must be a positive float less than or equal to top_p"
return
"
top_p
_bound must be a positive float less than or equal to top_p"
if
top_p
==
0.0
:
if
top_p
==
0.0
:
return
"
factual
_bound cannot be set without top_p"
return
"
top_p
_bound cannot be set without top_p"
if
not
(
0.0
<
factual
_bound
<=
top_p
):
if
not
(
0.0
<
top_p
_bound
<=
top_p
):
return
"
factual
_bound must be greater than 0 and less than top_p"
return
"
top_p
_bound must be greater than 0 and less than top_p"
add_BOS
=
False
add_BOS
=
False
if
"add_BOS"
in
request
.
get_json
():
if
"add_BOS"
in
request
.
get_json
():
...
@@ -163,8 +163,8 @@ class MegatronGenerate(Resource):
...
@@ -163,8 +163,8 @@ class MegatronGenerate(Resource):
return_output_log_probs
=
logprobs
,
return_output_log_probs
=
logprobs
,
top_k_sampling
=
top_k
,
top_k_sampling
=
top_k
,
top_p_sampling
=
top_p
,
top_p_sampling
=
top_p
,
factual_decay
=
factual
_decay
,
top_p_decay
=
top_p
_decay
,
factual_bound
=
factual
_bound
,
top_p_bound
=
top_p
_bound
,
temperature
=
temperature
,
temperature
=
temperature
,
add_BOS
=
add_BOS
,
add_BOS
=
add_BOS
,
use_eod_token_for_early_termination
=
True
,
use_eod_token_for_early_termination
=
True
,
...
...
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