Skip to content

Commit

Permalink
Allow setting top_p to 1.0 (mlc-ai#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickzx authored Apr 1, 2024
1 parent e4e2903 commit d20e08c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ export function postInitAndCheckGenerationConfigValues(config: GenerationConfig)
if (_hasValue(config.shift_fill_factor) && config.shift_fill_factor! <= 0 || config.shift_fill_factor! > 1) {
throw new Error("Make sure 0 < `shift_fill_factor` <= 1.");
}
if (_hasValue(config.top_p) && config.top_p! <= 0 || config.top_p! >= 1) {
throw new Error("Make sure 0 < `top_p` < 1.");
if (_hasValue(config.top_p) && config.top_p! <= 0 || config.top_p! > 1) {
throw new Error("Make sure 0 < `top_p` <= 1.");
}
if (_hasValue(config.temperature) && config.temperature! < 0) {
throw new Error("Make sure `temperature` >= 0.");
Expand Down
2 changes: 1 addition & 1 deletion src/llm_chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ export class LLMChatPipeline {
if (_hasValue(genConfig.top_logprobs)) { top_logprobs = genConfig.top_logprobs!; }
}
// Check range validity
if (top_p <= 0 || top_p >= 1) { throw new Error("Make sure 0 < `top_p` < 1."); }
if (top_p <= 0 || top_p > 1) { throw new Error("Make sure 0 < `top_p` <= 1."); }
if (temperature < 0) { throw new Error("Make sure `temperature` >= 0."); }
if (repetition_penalty <= 0) { throw new Error("Make sure `repetition_penalty` > 0."); }
if (frequency_penalty && (frequency_penalty < -2.0 || frequency_penalty > 2.0)) {
Expand Down

0 comments on commit d20e08c

Please sign in to comment.