Skip to content

[Feature] Support EBNF in xgrammar #2376

@merrymercy

Description

@merrymercy

Checklist

Motivation

xgrammar supports EBNF. We would like to integrate this feature into SGLang.

We can add a new parameter called ebnf in sampling_params.py and treat it similar to regex and JSON.

Related resources

https://xgrammar.mlc.ai/docs/how_to/ebnf_guided_generation.html

regex: Optional[str] = None,
n: int = 1,
json_schema: Optional[str] = None,

https://github.com/sgl-project/sglang/blob/main/test/srt/test_json_constrained.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions