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

Grammar Guided response from model. #4074

Open
NeevJewalkar opened this issue May 1, 2024 · 4 comments
Open

Grammar Guided response from model. #4074

NeevJewalkar opened this issue May 1, 2024 · 4 comments
Labels
feature request New feature or request

Comments

@NeevJewalkar
Copy link

Llama.cpp already has an implementation of grammars. Adding this to the ollama API, would bring more flexibility. This would also help in making reliable agentic llms.

@NeevJewalkar NeevJewalkar added the feature request New feature or request label May 1, 2024
@grantCelley
Copy link

There is a few PRs over the past year.

PR #565
Last updated: December 19th, 2024
The only thing I can tell is it opens up grammar from llama.cpp to the API. This was simple implementation but stopped it seems it was updated in pr #1606. This has merge conflicts.

PR #830
Last updated: April 29th, 2024
It allowed a json schema as the grammars. The last comment just explained why this is a good idea. Before that the last activity on the Pull request. This has merge conflicts.

PR #1606
Last updated: April 30th, 2024
This is an updated version of pr #565. This got a lot of comments. This has merge conflicts.

PR #3618
Last updated: April 23rd, 2024
This was an modification of pr #1606. It works for a JSON schema. It seems it worked as of April 23rd.

PR #2404
Last update: April 30th, 2024
This used format argument to allow grammar. Instead JSON you put in the Grammar. This is has conflicts now.

PR #2754
Last update: April 9th, 2024
This would allow a cli output onto ollama. This has conflicts now.

PR #3303
Last update: April 11th, 2024
This would add function calling. It says that it is a work in progress but does not have any recent activity nor any comments on how well this is going.

Why am I adding this to here?
This seems to be wanted by a bunch of people. None of the pull requests were merged and with 1.33 I think it caused a bunch of these pull requests not to work. I am trying to use LLMs for decision making. I need them to output in a standard format that I set.

Why aren't these merged yet?
I really don't know. This is something I am trying to figure out. I am wondering if this is not how the maintainers want the API to be. Some guidance would be nice.

@richardanaya
Copy link

richardanaya commented May 7, 2024

i am able to easily break Ollama's JSON support like this even with embedding JSON schema in prompts.

image

@NeevJewalkar
Copy link
Author

it wld be helpful if ollama had support for custom grammar, since the json grammar file provided by llama.cpp isnt really that helpful

@richardanaya
Copy link

I created an extensive PR for supporting grammar and go-side server validation here

#4525

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

3 participants