Unverified Commit c95bfc2e authored by Neal Vaidya's avatar Neal Vaidya Committed by GitHub
Browse files

fix: add force_nonempty_content for nemotron (#7225)


Signed-off-by: default avatarNeal Vaidya <nealv@nvidia.com>
parent 3513cc07
...@@ -1088,7 +1088,8 @@ impl OpenAIPreprocessor { ...@@ -1088,7 +1088,8 @@ impl OpenAIPreprocessor {
/// Check if reasoning parsing should be disabled based on per-request parameters. /// Check if reasoning parsing should be disabled based on per-request parameters.
/// For kimi_k25: disabled when chat_template_args contains "thinking": false. /// For kimi_k25: disabled when chat_template_args contains "thinking": false.
/// For nemotron_nano: disabled when chat_template_args contains "enable_thinking": false. /// For nemotron_nano: disabled when chat_template_args contains "enable_thinking": false
/// or "force_nonempty_content": true.
fn is_reasoning_disabled_by_request( fn is_reasoning_disabled_by_request(
reasoning_parser: Option<&str>, reasoning_parser: Option<&str>,
chat_template_args: Option<&std::collections::HashMap<String, serde_json::Value>>, chat_template_args: Option<&std::collections::HashMap<String, serde_json::Value>>,
...@@ -1102,11 +1103,18 @@ impl OpenAIPreprocessor { ...@@ -1102,11 +1103,18 @@ impl OpenAIPreprocessor {
} }
false false
} }
Some("nemotron_nano") => { Some("nemotron_nano") | Some("nemotron3") => {
if let Some(args) = chat_template_args if let Some(args) = chat_template_args {
&& let Some(enable_thinking) = args.get("enable_thinking") if let Some(enable_thinking) = args.get("enable_thinking")
{ && enable_thinking == &serde_json::Value::Bool(false)
return enable_thinking == &serde_json::Value::Bool(false); {
return true;
}
if let Some(force_nonempty) = args.get("force_nonempty_content")
&& force_nonempty == &serde_json::Value::Bool(true)
{
return true;
}
} }
false false
} }
......
...@@ -31,6 +31,7 @@ fn get_reasoning_parser_map() -> &'static HashMap<&'static str, ReasoningParserT ...@@ -31,6 +31,7 @@ fn get_reasoning_parser_map() -> &'static HashMap<&'static str, ReasoningParserT
map.insert("mistral", ReasoningParserType::Mistral); map.insert("mistral", ReasoningParserType::Mistral);
map.insert("granite", ReasoningParserType::Granite); map.insert("granite", ReasoningParserType::Granite);
map.insert("nemotron_nano", ReasoningParserType::DeepseekR1); // nemotron nano is ...</think> map.insert("nemotron_nano", ReasoningParserType::DeepseekR1); // nemotron nano is ...</think>
map.insert("nemotron3", ReasoningParserType::DeepseekR1);
map.insert("glm45", ReasoningParserType::NemotronDeci); // GLM-4.5/5 is <think>...</think>, no force_reasoning map.insert("glm45", ReasoningParserType::NemotronDeci); // GLM-4.5/5 is <think>...</think>, no force_reasoning
map.insert( map.insert(
"minimax_append_think", "minimax_append_think",
...@@ -249,6 +250,7 @@ mod tests { ...@@ -249,6 +250,7 @@ mod tests {
"mistral", "mistral",
"granite", "granite",
"nemotron_nano", "nemotron_nano",
"nemotron3",
"glm45", "glm45",
"minimax_append_think", "minimax_append_think",
]; ];
......
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