Skip to content

Conversation

ochafik
Copy link
Collaborator

@ochafik ochafik commented Apr 13, 2024

The server already has this (#5978), and the JSON schema support (#6555) and sampling speed (#6616, #6609 and #4306 before that) should now be good enough for more general use.

make clean && make LLAMA_CURL=1 -j main
./main \
  -mu https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF/resolve/main/Hermes-2-Pro-Mistral-7B.Q4_K_M.gguf \
  --log-disable --no-display-prompt
  -j '{"items": {"type": "string", "minLength": 3, "maxLength": 10}, "minItems": 10}' \
  -p 'Give me a list of things to do this weekend (e.g. ["Sleep in", "Shop T-shirts",...])' \

# [ "Sleep in", "Shop T-shirts", "Go to the beach", "See a movie", "Hike in the mountains", "Spend time with family", "Attend a concert", "Play video games", "Have a picnic", "Ride bikes"] 

Note that {} is the JSON schema for any JSON object:

./main \
  -mu https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF/resolve/main/Hermes-2-Pro-Mistral-7B.Q4_K_M.gguf \
  --log-disable --no-display-prompt \
  -j '{}' \
  --seed 42 \
  -p 'Make a plan for my life in JSON'

# { "goals": [ { "name": "Education", "subgoals": [ { "name": "Finish high school", "completion_date": "2023-06-30" }, { "name": "Get a college degree", "completion_date": "2027-05-31" } ] }, { "name": "Career", "subgoals": [ { "name": "Land a job in my field", "completion_date": "2023-09-01" }, { "name": "Get a promotion within 5 years", "completion_date": "2028-09-01" } ] }, { "name": "Personal development", "subgoals": [ { "name": "Learn a new skill", "completion_date": "2023-12-31" }, { "name": "Volunteer for a cause I care about", "completion_date": "2024-08-15" } ] } ] }

As a possible follow up, might wanna add support for external $refs or schema URL when building w/ libcurl (currently have to use --grammar "$( python examples/json_schema_to_grammar.py https://json.schemastore.org/tsconfig.json )")

@ochafik ochafik changed the title main: add --json-schema / -j flag main: add --json-schema / -j flag Apr 13, 2024
@ochafik ochafik marked this pull request as ready for review April 13, 2024 14:22
@ochafik ochafik merged commit 7593639 into ggml-org:master Apr 15, 2024
tybalex pushed a commit to rubra-ai/tools.cpp that referenced this pull request Apr 17, 2024
* main: add --json-schema / -j

* json: move json-schema-to-grammar to common lib

* json: fix zig build
tybalex pushed a commit to rubra-ai/tools.cpp that referenced this pull request Apr 18, 2024
* main: add --json-schema / -j

* json: move json-schema-to-grammar to common lib

* json: fix zig build
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