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]: Support JSON Schema from llama.cpp #798

Open
m0nsky opened this issue Jun 19, 2024 · 2 comments
Open

[Feature]: Support JSON Schema from llama.cpp #798

m0nsky opened this issue Jun 19, 2024 · 2 comments

Comments

@m0nsky
Copy link
Contributor

m0nsky commented Jun 19, 2024

Background & Description

I was working on a C# class -> GBNF converter, and came across this:

https://github.com/ggerganov/llama.cpp/blob/master/grammars/README.md#json-schemas--gbnf

Here's an example, thanks to this reddit post.

Example JSON:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "reply": {"type": "string"},
    "mood": {"type": "string"},
    "intent": {"type": "string"}
  },
  "required": ["reply", "mood", "intent"]
}

Example output:

 User: I gave you a cookie.

Please respond in JSON format with your reply, mood, and intent:
{"reply": "Thank you for the cookie! It's delicious!", "mood": "Happy", "intent": "Express gratitude" }

API & Usage

No response

How to implement

No response

@martindevans
Copy link
Member

Related: #309 ?

@m0nsky
Copy link
Contributor Author

m0nsky commented Jun 19, 2024

Yes somewhat, that PR sparked my initial interest in developing the C# class -> GBNF converter. However, the JSON Schema functionality seems to be already implemented on main & server on the llama.cpp side by passing the -j parameter, so it wouldn't make sense to reinvent the wheel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants