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

[Feature Request] Output Restricted by Context Free Grammar or JSON Schema #758

Closed
imaurer opened this issue Aug 15, 2023 · 1 comment
Closed
Labels
feature request New feature or request

Comments

@imaurer
Copy link

imaurer commented Aug 15, 2023

🚀 Feature

Pass in a grammar or JSON schema to restrict the output of generated tokens. This would make data extraction and potentially tool-usage use cases simpler to implement.

Motivation

Having the ability to constrain responses to a specified grammar or a JSON schema would unlock data extraction and function calling use cases.

Alternatives

Prompt-engineering isn't sufficient and not transferrable between models.
Fine-tuning would be a much heavier lift compared a grammar that could drive output.

Additional context

Some prior art to consider:
ggml-org/llama.cpp#1773
https://huggingface.co/spaces/mishig/jsonformer
https://github.com/normal-computing/outlines
https://github.com/r2d4/rellm

Great project, I have been able to get highly performant and high quality response in a couple of hours of effort. Huge kudos to the MLC team and to Simon Willison for this project that got me started with his llm library:

https://github.com/simonw/llm-mlc

@imaurer imaurer added the feature request New feature or request label Aug 15, 2023
@mondaychen
Copy link

Probably duplicate of #499
It seems to me it's out of scope for this project to have native support for JSON schema.
We can easily apply a layer like outlines on top of a MLC LLM if the support for something like logits_processor is added

@imaurer imaurer closed this as completed Aug 15, 2023
@imaurer imaurer closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants