Skip to content

Conversation

gaocegege
Copy link
Contributor

@gaocegege gaocegege commented Feb 8, 2025

Ref #12619

Only apply Guided/Structured grammar after reasoning steps in Reasoning models. It enabled reasoning outputs for xgrammar and outlines, didn't support lm-format-enforcer.

Usage:

vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --enable-reasoning --reasoning-parser deepseek_r1
prompt = ("Generate a JSON with the brand, model and car_type of"
          "the most iconic car from the 90's, think in 100 tokens")
completion = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
    messages=[{
        "role": "user",
        "content": prompt,
    }],
    extra_body={"guided_json": json_schema},
)
print("content: ", completion.choices[0].message.content)
print("reasoning_content: ", completion.choices[0].message.reasoning_content)
content: {

"brand": "Levels",
"model": "racing equation",
"car_type": "sedan"
}
reasoning_content:  
Okay, the user is asking me to generate a JSON with the brand, model, and car type of the most iconic 90s car. I need to make sure it's within 100 tokens. Let me start by recalling some of the most significant cars from the 90s.型号 race cars are a big category, so theathy and V8 are definitely in there.马路超车 automotive should be in as well.

I need to find the brand.Levels was really influential, especially in racing. So the brand should be Levels. The model is the race car itself, maybe racing equations since they were a big trend. The engine details: a 7.5-litreUnused to make sense of the information, but I'll have to include it as it's important for the context.

Fact checking is crucial. The 90s included the Formula 1 series, which was growing. Yes, L charcoal was a key driver there. Values of engines and tests set a benchmark. B gjvertern is part of the马路 coder project, and P race appears to be another race series.

I should structure the JSON without parentheticals and make sure each field is clearly defined. Let me make a mental note to keep it concise. I'll write the JSON, making sure it neither uses more than 90 tokens nor exceeds that number. Finally, I'll double-check to ensure accuracy without making any mistakes.

Copy link

github-actions bot commented Feb 8, 2025

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@gaocegege gaocegege changed the title feat: Support reasoning outputs in xgrammar [v0] feat: Support reasoning outputs in xgrammar Feb 8, 2025
@gaocegege gaocegege marked this pull request as ready for review February 9, 2025 01:57
@gaocegege gaocegege force-pushed the reasoning_structured branch from a2c9058 to f5ec168 Compare February 9, 2025 02:07
@gaocegege gaocegege changed the title [v0] feat: Support reasoning outputs in xgrammar [v0] feat: Support reasoning outputs in structured outputs Feb 9, 2025
@gaocegege gaocegege force-pushed the reasoning_structured branch from 50be0e9 to 6b76121 Compare February 9, 2025 03:52
@mergify mergify bot added the documentation Improvements or additions to documentation label Feb 11, 2025
@gaocegege gaocegege force-pushed the reasoning_structured branch from 8416648 to 3034e5c Compare February 19, 2025 01:49
@gaocegege
Copy link
Contributor Author

@russellb Could you please help review this PR?

@gaocegege gaocegege force-pushed the reasoning_structured branch from 3034e5c to eaaced1 Compare February 19, 2025 01:58
@gaocegege gaocegege changed the title [v0] feat: Support reasoning outputs in structured outputs [v0][structured output] Support reasoning output Feb 19, 2025
@gaocegege
Copy link
Contributor Author

Please let me know if anyone is ready to review and merge this. Once confirmed, I will resolve the conflicts here. It’s time-consuming to address them daily.

Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have few questions regarding implementations, otherwise lgtm

Copy link

mergify bot commented Feb 25, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @gaocegege.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Feb 25, 2025
@gaocegege gaocegege force-pushed the reasoning_structured branch from 471eb35 to 80bce05 Compare February 26, 2025 01:54
@mergify mergify bot removed the needs-rebase label Feb 26, 2025
gaocegege added 10 commits March 1, 2025 09:19
Signed-off-by: Ce Gao <[email protected]>
Signed-off-by: Ce Gao <[email protected]>
Signed-off-by: Ce Gao <[email protected]>
Signed-off-by: Ce Gao <[email protected]>
Signed-off-by: Ce Gao <[email protected]>
Signed-off-by: Ce Gao <[email protected]>
Signed-off-by: Ce Gao <[email protected]>
Signed-off-by: Ce Gao <[email protected]>
Copy link
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great progress on this feature @gaocegege !

@mgoin mgoin merged commit bf33700 into vllm-project:main Mar 2, 2025
40 checks passed
@gaocegege
Copy link
Contributor Author

Thanks for your review @aarnphm @mgoin

@gaocegege gaocegege deleted the reasoning_structured branch March 3, 2025 02:14
Akshat-Tripathi pushed a commit to krai/vllm that referenced this pull request Mar 3, 2025
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation frontend ready ONLY add when PR is ready to merge/full CI is needed structured-output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants