Commit ed6806ac authored by rprenger's avatar rprenger
Browse files

Changing name of parameters from factual_decay to top_p_decay

parent b49349ec
......@@ -33,8 +33,8 @@ def generate_and_post_process(model,
return_output_log_probs=False,
top_k_sampling=0,
top_p_sampling=0.0,
factual_decay=0.0,
factual_bound=0.0,
top_p_decay=0.0,
top_p_bound=0.0,
temperature=1.0,
add_BOS=False,
use_eod_token_for_early_termination=True,
......@@ -52,8 +52,8 @@ def generate_and_post_process(model,
return_output_log_probs=return_output_log_probs,
top_k_sampling=top_k_sampling,
top_p_sampling=top_p_sampling,
factual_decay=factual_decay,
factual_bound=factual_bound,
top_p_decay=top_p_decay,
top_p_bound=top_p_bound,
temperature=temperature,
add_BOS=add_BOS,
use_eod_token_for_early_termination=use_eod_token_for_early_termination,
......@@ -82,8 +82,8 @@ def generate(model,
return_output_log_probs=False,
top_k_sampling=0,
top_p_sampling=0.0,
factual_decay=0.0,
factual_bound=0.0,
top_p_decay=0.0,
top_p_bound=0.0,
temperature=1.0,
add_BOS=False,
use_eod_token_for_early_termination=True,
......@@ -101,7 +101,7 @@ def generate(model,
# Make sure input params are avaialble to all ranks.
values = [tokens_to_generate,
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,
stop_on_double_eol,
stop_on_eol,
......@@ -111,8 +111,8 @@ def generate(model,
return_output_log_probs = bool(values_float_tensor[1].item())
top_k_sampling = int(values_float_tensor[2].item())
top_p_sampling = values_float_tensor[3].item()
factual_decay = values_float_tensor[4].item()
factual_bound = values_float_tensor[5].item()
top_p_decay = values_float_tensor[4].item()
top_p_bound = values_float_tensor[5].item()
temperature = values_float_tensor[6].item()
add_BOS = bool(values_float_tensor[7].item())
use_eod_token_for_early_termination = bool(values_float_tensor[8].item())
......@@ -142,8 +142,8 @@ def generate(model,
return_output_log_probs=return_output_log_probs,
top_k=top_k_sampling,
top_p=top_p_sampling,
factual_decay=factual_decay,
factual_bound=factual_bound,
top_p_decay=top_p_decay,
top_p_bound=top_p_bound,
temperature=temperature,
use_eod_token_for_early_termination=use_eod_token_for_early_termination,
stop_on_double_eol=stop_on_double_eol,
......
......@@ -94,7 +94,7 @@ def score_and_return_on_first_stage(model, tokens, lengths):
def generate_tokens_probs_and_return_on_first_stage(
model, tokens, lengths,
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,
use_eod_token_for_early_termination=True,
stop_on_double_eol=False,
......@@ -200,10 +200,10 @@ def generate_tokens_probs_and_return_on_first_stage(
top_p=top_p,
temperature=temperature,
vocab_size=tokenizer.vocab_size)
if top_p > 0.0 and factual_decay > 0.0:
top_p = top_p * factual_decay
if factual_bound > 0.0:
top_p = max(top_p, factual_bound)
if top_p > 0.0 and top_p_decay > 0.0:
top_p = top_p * top_p_decay
if top_p_bound > 0.0:
top_p = max(top_p, top_p_bound)
# If a prompt length is smaller or equal th current context
# length, it means we have started generating tokens
......
......@@ -93,25 +93,25 @@ class MegatronGenerate(Resource):
if not (0 <= top_p <= 1.0):
return "top_p must be less than or equal to 1.0"
factual_decay = 0.0
if "factual_decay" in request.get_json():
factual_decay = request.get_json()["factual_decay"]
if not (type(factual_decay) == float):
return "factual_decay must be a positive float less than or equal to 1.0"
top_p_decay = 0.0
if "top_p_decay" in request.get_json():
top_p_decay = request.get_json()["top_p_decay"]
if not (type(top_p_decay) == float):
return "top_p_decay must be a positive float less than or equal to 1.0"
if top_p == 0.0:
return "factual_decay cannot be set without top_p"
if not (0 <= factual_decay <= 1.0):
return "factual_decay must be less than or equal to 1.0"
return "top_p_decay cannot be set without top_p"
if not (0 <= top_p_decay <= 1.0):
return "top_p_decay must be less than or equal to 1.0"
factual_bound = 0.0
if "factual_bound" in request.get_json():
factual_bound = request.get_json()["factual_bound"]
if not (type(factual_bound) == float):
return "factual_bound must be a positive float less than or equal to top_p"
top_p_bound = 0.0
if "top_p_bound" in request.get_json():
top_p_bound = request.get_json()["top_p_bound"]
if not (type(top_p_bound) == float):
return "top_p_bound must be a positive float less than or equal to top_p"
if top_p == 0.0:
return "factual_bound cannot be set without top_p"
if not (0.0 < factual_bound <= top_p):
return "factual_bound must be greater than 0 and less than top_p"
return "top_p_bound cannot be set without top_p"
if not (0.0 < top_p_bound <= top_p):
return "top_p_bound must be greater than 0 and less than top_p"
add_BOS = False
if "add_BOS" in request.get_json():
......@@ -163,8 +163,8 @@ class MegatronGenerate(Resource):
return_output_log_probs=logprobs,
top_k_sampling=top_k,
top_p_sampling=top_p,
factual_decay=factual_decay,
factual_bound=factual_bound,
top_p_decay=top_p_decay,
top_p_bound=top_p_bound,
temperature=temperature,
add_BOS=add_BOS,
use_eod_token_for_early_termination=True,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment