vllm.reasoning.hunyuan_a13b_reasoning_parser
HunyuanA13BReasoningParser ¶
Bases: ReasoningParser
Reasoning parser for Hunyuan A13B Model
HunyuanReasoningParser
This class implements a reasoning parser specifically designed
for the Hunyuan A13B Model. It is responsible for parsing and
extracting structured reasoning and answer segments from model
outputs that follow a specific pattern.
Key Features:
- For non-stream output , Recognizes and extracts reasoning ("think")
and answer ("answer") sections from text using regular expressions.
- For stream process, it require a token id sequences to change the
reasoning state and other state so it maintains internal state to
manage parsing across multiple token.
think start: "<think>
": [14023, 771, 397] think ends: "
Source code in vllm/reasoning/hunyuan_a13b_reasoning_parser.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
fast_think_ids instance-attribute
¶
full_match_reasoning_regex instance-attribute
¶
full_match_reasoning_regex = compile(
f"(?:{think_start_expr}(.*?){response_start_expr})?(.*?){response_end_expr}",
DOTALL,
)
half_match_reasoning_regex instance-attribute
¶
half_match_reasoning_regex = compile(
f"{think_start_expr}(.*?){response_start_expr}(.*)",
DOTALL,
)
response_start_ids_fast instance-attribute
¶
__init__ ¶
Source code in vllm/reasoning/hunyuan_a13b_reasoning_parser.py
_is_strict_increasing_subsequence ¶
Source code in vllm/reasoning/hunyuan_a13b_reasoning_parser.py
extract_content_ids ¶
Source code in vllm/reasoning/hunyuan_a13b_reasoning_parser.py
extract_reasoning_content ¶
extract_reasoning_content(
model_output: str, request: ChatCompletionRequest
) -> tuple[Optional[str], Optional[str]]
Extract the reasoning content & content sections, respectively. If the sequence doesn't match what we expect, i.e., the model generates something else, all content is considered non-reasoning content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_output | str | Output of the model to be parsed. | required |
request | ChatCompletionRequest | Request being processed. | required |
Returns:
Type | Description |
---|---|
Optional[str] | tuple[Optional[str], Optional[str]]: Tuple pair containing the |
Optional[str] | reasoning content and non-reasoning content. |
Source code in vllm/reasoning/hunyuan_a13b_reasoning_parser.py
extract_reasoning_content_streaming ¶
extract_reasoning_content_streaming(
previous_text: str,
current_text: str,
delta_text: str,
previous_token_ids: Sequence[int],
current_token_ids: Sequence[int],
delta_token_ids: Sequence[int],
) -> Union[DeltaMessage, None]
Extract content using token ID sequence state machine
Source code in vllm/reasoning/hunyuan_a13b_reasoning_parser.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|