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

WIP add json-schema grammar test from llama.cpp #1

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

marcnnn
Copy link

@marcnnn marcnnn commented Sep 22, 2024

This commit adds tests for all grammar from
https://github.com/ggerganov/llama.cpp/blob/master/tests/test-json-schema-to-grammar.cpp

Many fail because the regex operator to repeat
{from,to} many times seems not implemented.

And some other problems.

@seanmor5 Thanks for all your work!

I would love to help with elixir-nx/bumblebee#354, but to get into understanding the difficulties I started here.

To get to the goal of Constrained sampling with rich JSON-schema support for tool calling in Elixir.

Since you have no License on the Project, is adding the grammars from the llama.cpp (MIT License) code okay for you?

This commit adds tests for all grammar from
https://github.com/ggerganov/llama.cpp/blob/master/tests/test-json-schema-to-grammar.cpp

Many fail because the regex operator to repeat
{from,to} many times seems not implemented.

And some other problems.
@seanmor5
Copy link
Owner

@marcnnn Thank you for including these! I can look at adding {from, to} support. I think it's fine adding grammars from llama.cpp as well

This library is unfinished, but the idea was to be able to parse EBNF grammars into a state that could basically be used as a state machine during sampling. There are some challenges in Nx specifically that make this more difficult, specifically that each input to a generation algorithm needs to be a tensor with a static shape. I haven't had time to look at this problem in awhile, but I can assist if it's something you're interested in working on! I originally took inspiration from a PR in the huggingface repo; however, I think there are other approaches that are worth exploring from vllm and elsewhere. I am in the EEF ML Slack if you want to ping me there to chat about how we can achieve this

@marcnnn marcnnn force-pushed the WIP-json-schema-grammar-llama-cpp branch from 43de27c to c639423 Compare October 7, 2024 16:54
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