Skip to content

Conversation

shuaills
Copy link
Collaborator

@shuaills shuaills commented Dec 22, 2024

Motivation

Improve documentation clarity around grammar backends.

#2505

Modifications

Updated documentation to clarify Xgrammar's JSON support and regex limitation.

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

@zhaochenyang20 zhaochenyang20 changed the title Related to #2505 Updated documentation to clarify Xgrammar features. Updated documentation for Grammar Backend Dec 22, 2024
@@ -223,6 +223,13 @@
"## Structured decoding (JSON, Regex)\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can define a JSON schema or regular expression to constrain the model's output, which depends on the grammar backend.

SGlang has two backends: outlines (default) and Xgrammar. Xgrammar enhances JSON decoding performance but does not support regular expressions. To use Xgrammar, add --grammar-backend xgrammar when launching the server:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated and verified the functionality with Xgrammar backend.

@zhaochenyang20
Copy link
Collaborator

This is just to update the current document, so a tiny modification is good enough. However, for the constraint decoding tutorial, please truly launch the server to check its correctness. Also, what's the status of the tutorial? @shuaills

@shuaills
Copy link
Collaborator Author

shuaills commented Dec 22, 2024

This is just to update the current document, so a tiny modification is good enough. However, for the constraint decoding tutorial, please truly launch the server to check its correctness. Also, what's the status of the tutorial? @shuaills

I'm working on it. Should it be in Jupyter Notebook format? And where should I put the tutorial?

@zhaochenyang20
Copy link
Collaborator

This is just to update the current document, so a tiny modification is good enough. However, for the constraint decoding tutorial, please truly launch the server to check its correctness. Also, what's the status of the tutorial? @shuaills

I'm working on it. Should it be in Jupyter Notebook format? And where should I put the tutorial?

It should be a Notebook. Put it under docs/backend

Copy link
Collaborator

@zhaochenyang20 zhaochenyang20 left a comment

Choose a reason for hiding this comment

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

Just tiny modification. Then we can merge it.

@zhaochenyang20 zhaochenyang20 enabled auto-merge (squash) December 22, 2024 23:48
@zhaochenyang20 zhaochenyang20 enabled auto-merge (squash) December 23, 2024 00:15
@zhaochenyang20 zhaochenyang20 merged commit 25e5d58 into sgl-project:main Dec 23, 2024
2 checks passed
@shuaills shuaills deleted the docs/structured-decoding-updates branch December 29, 2024 07:11
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
Co-authored-by: Chayenne <zhaochen20@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants