Unverified Commit 0b3a5b11 authored by Xinyuan Tong's avatar Xinyuan Tong Committed by GitHub
Browse files

Update reasoning parser doc (#9468)


Signed-off-by: default avatarXinyuan Tong <xinyuantong.cs@gmail.com>
parent 6c855db8
...@@ -115,17 +115,17 @@ ...@@ -115,17 +115,17 @@
"\n", "\n",
"```python\n", "```python\n",
"# Launch server:\n", "# Launch server:\n",
"# python3 -m sglang.launch_server --model-path QwQ/Qwen3-32B-250415 --reasoning-parser qwen3\n", "# python3 -m sglang.launch_server --model Qwen/Qwen3-4B --reasoning-parser qwen3\n",
"\n", "\n",
"from openai import OpenAI\n", "from openai import OpenAI\n",
"\n", "\n",
"client = OpenAI(\n", "client = OpenAI(\n",
" api_key=\"EMPTY\",\n", " api_key=\"EMPTY\",\n",
" base_url=f\"http://127.0.0.1:{port}/v1\",\n", " base_url=f\"http://127.0.0.1:30000/v1\",\n",
")\n", ")\n",
"\n", "\n",
"model = \"QwQ/Qwen3-32B-250415\"\n", "model = \"Qwen/Qwen3-4B\"\n",
"messages = [{\"role\": \"user\", \"content\": \"9.11 and 9.8, which is greater?\"}]\n", "messages = [{\"role\": \"user\", \"content\": \"How many r's are in 'strawberry'?\"}]\n",
"\n", "\n",
"response = client.chat.completions.create(\n", "response = client.chat.completions.create(\n",
" model=model,\n", " model=model,\n",
...@@ -137,13 +137,28 @@ ...@@ -137,13 +137,28 @@
")\n", ")\n",
"\n", "\n",
"print(\"Reasoning:\", response.choices[0].message.reasoning_content)\n", "print(\"Reasoning:\", response.choices[0].message.reasoning_content)\n",
"print(\"-\"*100)\n",
"print(\"Answer:\", response.choices[0].message.content)\n", "print(\"Answer:\", response.choices[0].message.content)\n",
"```\n", "```\n",
"\n", "\n",
"**Output:**\n", "**ExampleOutput:**\n",
"```\n", "```\n",
"Reasoning: Okay, so I need to figure out which number is greater between 9.11 and 9.8...\n", "Reasoning: Okay, so the user is asking how many 'r's are in the word 'strawberry'. Let me think. First, I need to make sure I have the word spelled correctly. Strawberry... S-T-R-A-W-B-E-R-R-Y. Wait, is that right? Let me break it down.\n",
"Answer: 9.8 is greater than 9.11.\n", "\n",
"Starting with 'strawberry', let's write out the letters one by one. S, T, R, A, W, B, E, R, R, Y. Hmm, wait, that's 10 letters. Let me check again. S (1), T (2), R (3), A (4), W (5), B (6), E (7), R (8), R (9), Y (10). So the letters are S-T-R-A-W-B-E-R-R-Y. \n",
"...\n",
"Therefore, the answer should be three R's in 'strawberry'. But I need to make sure I'm not counting any other letters as R. Let me check again. S, T, R, A, W, B, E, R, R, Y. No other R's. So three in total. Yeah, that seems right.\n",
"\n",
"----------------------------------------------------------------------------------------------------\n",
"Answer: The word \"strawberry\" contains **three** letters 'r'. Here's the breakdown:\n",
"\n",
"1. **S-T-R-A-W-B-E-R-R-Y** \n",
" - The **third letter** is 'R'. \n",
" - The **eighth and ninth letters** are also 'R's. \n",
"\n",
"Thus, the total count is **3**. \n",
"\n",
"**Answer:** 3.\n",
"```\n", "```\n",
"\n", "\n",
"**Note:** Setting `\"enable_thinking\": False` (or omitting it) will result in `reasoning_content` being `None`. Qwen3-Thinking models always generate reasoning content and don't support the `enable_thinking` parameter.\n" "**Note:** Setting `\"enable_thinking\": False` (or omitting it) will result in `reasoning_content` being `None`. Qwen3-Thinking models always generate reasoning content and don't support the `enable_thinking` parameter.\n"
...@@ -159,17 +174,17 @@ ...@@ -159,17 +174,17 @@
"\n", "\n",
"```python\n", "```python\n",
"# Launch server:\n", "# Launch server:\n",
"# python3 -m sglang.launch_server --model-path deepseek-ai/DeepSeek-V3 --reasoning-parser deepseek-v3\n", "# python3 -m sglang.launch_server --model deepseek-ai/DeepSeek-V3.1 --tp 8 --reasoning-parser deepseek-v3\n",
"\n", "\n",
"from openai import OpenAI\n", "from openai import OpenAI\n",
"\n", "\n",
"client = OpenAI(\n", "client = OpenAI(\n",
" api_key=\"EMPTY\",\n", " api_key=\"EMPTY\",\n",
" base_url=f\"http://127.0.0.1:{port}/v1\",\n", " base_url=f\"http://127.0.0.1:30000/v1\",\n",
")\n", ")\n",
"\n", "\n",
"model = \"deepseek-ai/DeepSeek-V3\"\n", "model = \"deepseek-ai/DeepSeek-V3.1\"\n",
"messages = [{\"role\": \"user\", \"content\": \"What is 2^8?\"}]\n", "messages = [{\"role\": \"user\", \"content\": \"How many r's are in 'strawberry'?\"}]\n",
"\n", "\n",
"response = client.chat.completions.create(\n", "response = client.chat.completions.create(\n",
" model=model,\n", " model=model,\n",
...@@ -181,21 +196,30 @@ ...@@ -181,21 +196,30 @@
")\n", ")\n",
"\n", "\n",
"print(\"Reasoning:\", response.choices[0].message.reasoning_content)\n", "print(\"Reasoning:\", response.choices[0].message.reasoning_content)\n",
"print(\"-\"*100)\n",
"print(\"Answer:\", response.choices[0].message.content)\n", "print(\"Answer:\", response.choices[0].message.content)\n",
"```\n", "```\n",
"\n", "\n",
"**Output:**\n", "**Example Output:**\n",
"```\n", "```\n",
"Reasoning: <think>I need to calculate 2^8. Let me work through this step by step:\n", "Reasoning: First, the question is: \"How many r's are in 'strawberry'?\"\n",
"2^1 = 2\n", "\n",
"2^2 = 4\n", "I need to count the number of times the letter 'r' appears in the word \"strawberry\".\n",
"2^3 = 8\n", "\n",
"2^4 = 16\n", "Let me write out the word: S-T-R-A-W-B-E-R-R-Y.\n",
"2^5 = 32\n", "\n",
"2^6 = 64\n", "Now, I'll go through each letter and count the 'r's.\n",
"2^7 = 128\n", "...\n",
"2^8 = 256</think>\n", "So, I have three 'r's in \"strawberry\".\n",
"Answer: 2^8 equals 256.\n", "\n",
"I should double-check. The word is spelled S-T-R-A-W-B-E-R-R-Y. The letters are at positions: 3, 8, and 9 are 'r's. Yes, that's correct.\n",
"\n",
"Therefore, the answer should be 3.\n",
"----------------------------------------------------------------------------------------------------\n",
"Answer: The word \"strawberry\" contains **3** instances of the letter \"r\". Here's a breakdown for clarity:\n",
"\n",
"- The word is spelled: S-T-R-A-W-B-E-R-R-Y\n",
"- The \"r\" appears at the 3rd, 8th, and 9th positions.\n",
"```\n", "```\n",
"\n", "\n",
"**Note:** DeepSeek-V3 models use the `thinking` parameter (not `enable_thinking`) to control reasoning output.\n" "**Note:** DeepSeek-V3 models use the `thinking` parameter (not `enable_thinking`) to control reasoning output.\n"
......
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