[Rust Frontend] Add seed_oss and step3p5 reasoning parsers (#44552)
Signed-off-by: yzhan1 <zhanyaoming2014@gmail.com>
This commit is contained in:
@@ -272,6 +272,6 @@ mod tests {
|
||||
)
|
||||
.unwrap_err();
|
||||
|
||||
expect_test::expect!["reasoning parser `definitely_missing_reasoning_parser` is not registered (choose from: cohere_cmd, deepseek_r1, deepseek_v3, deepseek_v4, gemma4, glm45, kimi, kimi_k2, minimax_m2, nemotron_v3, qwen3, step3)"].assert_eq(&error.to_report_string());
|
||||
expect_test::expect!["reasoning parser `definitely_missing_reasoning_parser` is not registered (choose from: cohere_cmd, deepseek_r1, deepseek_v3, deepseek_v4, gemma4, glm45, kimi, kimi_k2, minimax_m2, nemotron_v3, qwen3, seed_oss, step3, step3p5)"].assert_eq(&error.to_report_string());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ pub use vllm_reasoning_parser::{
|
||||
CohereCmdReasoningParser, DeepSeekR1ReasoningParser, DeepSeekV3ReasoningParser,
|
||||
DeepSeekV4ReasoningParser, Gemma4ReasoningParser, Glm45ReasoningParser, KimiK2ReasoningParser,
|
||||
KimiReasoningParser, MiniMaxM2ReasoningParser, NemotronV3ReasoningParser, Qwen3ReasoningParser,
|
||||
ReasoningDelta, ReasoningError, ReasoningParser, Step3ReasoningParser,
|
||||
ReasoningDelta, ReasoningError, ReasoningParser, SeedOssReasoningParser, Step3ReasoningParser,
|
||||
Step3p5ReasoningParser,
|
||||
};
|
||||
use vllm_tokenizer::DynTokenizer;
|
||||
|
||||
@@ -25,7 +26,9 @@ pub mod names {
|
||||
pub const MINIMAX_M2: &str = "minimax_m2";
|
||||
pub const NEMOTRON_V3: &str = "nemotron_v3";
|
||||
pub const QWEN3: &str = "qwen3";
|
||||
pub const SEED_OSS: &str = "seed_oss";
|
||||
pub const STEP3: &str = "step3";
|
||||
pub const STEP3P5: &str = "step3p5";
|
||||
}
|
||||
|
||||
/// Constructor signature for one registered reasoning parser implementation.
|
||||
@@ -61,7 +64,9 @@ impl ReasoningParserFactory {
|
||||
.register_parser::<MiniMaxM2ReasoningParser>(names::MINIMAX_M2)
|
||||
.register_parser::<NemotronV3ReasoningParser>(names::NEMOTRON_V3)
|
||||
.register_parser::<Qwen3ReasoningParser>(names::QWEN3)
|
||||
.register_parser::<Step3ReasoningParser>(names::STEP3);
|
||||
.register_parser::<SeedOssReasoningParser>(names::SEED_OSS)
|
||||
.register_parser::<Step3ReasoningParser>(names::STEP3)
|
||||
.register_parser::<Step3p5ReasoningParser>(names::STEP3P5);
|
||||
|
||||
factory
|
||||
.register_pattern("deepseek-r1", names::DEEPSEEK_R1)
|
||||
@@ -77,7 +82,14 @@ impl ReasoningParserFactory {
|
||||
.register_pattern("glm-4.5", names::GLM45)
|
||||
.register_pattern("kimi-k2", names::KIMI_K2)
|
||||
.register_pattern("kimi", names::KIMI)
|
||||
// step3p5 patterns must precede `step3`: substring matching would
|
||||
// otherwise route step3p5 IDs to step3.
|
||||
.register_pattern("step-3p5", names::STEP3P5)
|
||||
.register_pattern("step3p5", names::STEP3P5)
|
||||
.register_pattern("step-3.5", names::STEP3P5)
|
||||
.register_pattern("step3", names::STEP3)
|
||||
.register_pattern("seed-oss", names::SEED_OSS)
|
||||
.register_pattern("seedoss", names::SEED_OSS)
|
||||
.register_pattern("minimax", names::MINIMAX_M2)
|
||||
.register_pattern("mm-m2", names::MINIMAX_M2)
|
||||
.register_pattern("cohere", names::COHERE_CMD)
|
||||
|
||||
@@ -32,8 +32,12 @@ fn factory_contains_and_lists_registered_parsers() {
|
||||
let factory = ReasoningParserFactory::new();
|
||||
assert!(factory.contains(names::QWEN3));
|
||||
assert!(factory.contains(names::DEEPSEEK_V4));
|
||||
assert!(factory.contains(names::SEED_OSS));
|
||||
assert!(factory.contains(names::STEP3P5));
|
||||
assert!(factory.list().contains(&names::QWEN3.to_string()));
|
||||
assert!(factory.list().contains(&names::DEEPSEEK_V4.to_string()));
|
||||
assert!(factory.list().contains(&names::SEED_OSS.to_string()));
|
||||
assert!(factory.list().contains(&names::STEP3P5.to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -49,6 +53,41 @@ fn factory_resolves_deepseek_v4_to_qwen3_alias() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factory_routes_step3p5_models_to_dedicated_parser() {
|
||||
let factory = ReasoningParserFactory::new();
|
||||
// step3p5 patterns must beat the bare `step3` substring.
|
||||
assert_eq!(
|
||||
factory.resolve_name_for_model("step-3p5-instruct"),
|
||||
Some(names::STEP3P5)
|
||||
);
|
||||
assert_eq!(
|
||||
factory.resolve_name_for_model("step3p5"),
|
||||
Some(names::STEP3P5)
|
||||
);
|
||||
assert_eq!(
|
||||
factory.resolve_name_for_model("step-3.5-base"),
|
||||
Some(names::STEP3P5)
|
||||
);
|
||||
assert_eq!(
|
||||
factory.resolve_name_for_model("step3-base"),
|
||||
Some(names::STEP3)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factory_routes_seed_oss_models() {
|
||||
let factory = ReasoningParserFactory::new();
|
||||
assert_eq!(
|
||||
factory.resolve_name_for_model("ByteDance-Seed/Seed-OSS-36B-Instruct"),
|
||||
Some(names::SEED_OSS)
|
||||
);
|
||||
assert_eq!(
|
||||
factory.resolve_name_for_model("seedoss-7b"),
|
||||
Some(names::SEED_OSS)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factory_rejects_unknown_parser_names() {
|
||||
let tokenizer = Arc::new(FakeTokenizer);
|
||||
|
||||
@@ -144,6 +144,30 @@ impl RoundtripCase {
|
||||
json_fmt: spaced_json_fmt(),
|
||||
}
|
||||
}
|
||||
|
||||
/// SeedOSS with `<seed:think>` / `</seed:think>` reasoning tags.
|
||||
fn seed_oss() -> Self {
|
||||
Self {
|
||||
model_id: "ByteDance-Seed/Seed-OSS-36B-Instruct",
|
||||
assistant_stop_suffix: "<seed:eos>",
|
||||
tool_call_parser: ParserSelection::Auto,
|
||||
reasoning_parser: ParserSelection::Auto,
|
||||
thinking_behavior: ThinkingBehavior::Always { value: true },
|
||||
json_fmt: compact_json_fmt(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Step-3.5 with `<think>` / `</think>` reasoning tags and newline trimming.
|
||||
fn step3p5() -> Self {
|
||||
Self {
|
||||
model_id: "stepfun-ai/Step-3.5-Flash",
|
||||
assistant_stop_suffix: "<|im_end|>\n",
|
||||
tool_call_parser: ParserSelection::Auto,
|
||||
reasoning_parser: ParserSelection::Auto,
|
||||
thinking_behavior: ThinkingBehavior::Always { value: true },
|
||||
json_fmt: compact_json_fmt(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! roundtrip_tests {
|
||||
@@ -168,6 +192,8 @@ roundtrip_tests! {
|
||||
minimax_m25 => [reasoning_and_content, tool_call_mix],
|
||||
deepseek_v4 => [reasoning_and_content, tool_call_mix],
|
||||
glm47 => [reasoning_and_content, tool_call_mix],
|
||||
seed_oss => [reasoning_and_content],
|
||||
step3p5 => [reasoning_and_content],
|
||||
|
||||
// Note: Kimi K2.5 strips the reasoning content in history.
|
||||
kimi_k25 => [tool_call_mix],
|
||||
|
||||
Reference in New Issue
Block a user