Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated documentation for Grammar Backend #2545

Merged

Conversation

shuaills
Copy link
Contributor

@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
Contributor 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
Contributor 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.

docs/backend/openai_api_completions.ipynb Outdated Show resolved Hide resolved
@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
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