-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
json
: unified properties order across optional & required
#8133
base: master
Are you sure you want to change the base?
Conversation
Unrelated to this PR, but I am mentioning this here since you are working on this. The |
@slaren oh that's weird, looks like it's timing out in the node.js portion of the test, although without timestamped logs it's not clear if the C++ or (more likely) the Python versions are (also) to blame. If the flakiness is an issue I'd opt to modify the LLAMA_NODE_AVAILABLE & python logic in the test to just let any CI runner relying on an emulator skip both the python & js branches (+ file a bug for me to investigate further, I've certainly optimised the latest changes for ease of writing & cross-language portability rather than speed 😅) |
Currently seems this is a bit slower than # git add remote ochafik https://github.com/ochafik/llama.cpp
# git fetch ochafik
python examples/json_schema_to_grammar.py \
https://json.schemastore.org/tsconfig.json \
> grammars/tsconfig.json.gbnf
hyperfine --warmup 1 --runs 10 \
-L branch master,ochafik/json-order \
--setup 'git checkout {branch} && \
make clean && \
make -j LLAMA_CURL=1 llama-cli' \
'BRANCH={branch} \
./llama-cli --grammar-file grammars/tsconfig.json.gbnf \
-p "Write a tsconfig.json for a simple project with strict types incremental compiler/build options:" \
-mu https://huggingface.co/bartowski/Meta-Llama-3-8B-Instruct-GGUF/resolve/main/Meta-Llama-3-8B-Instruct-Q8_0.gguf \
--seed 13345'
|
This makes properties to be generated in the order they're defined, no matter whether they're optional or required
(Follow up to #7840 (comment), cc/ @HanClinto )
Before this PR, required properties were generated first (and order is then following definition within group of required & optional props):
After, all properties appear in a unified order:
This has the added benefit of reducing the max number of parallel alternatives, which should speed grammar sampling up.
TODO:
Merge
json
: restore default additionalProperties to false, fix some pattern escapes #8180 first (restore defaultadditionalProperties
to fals and fix tsconfig.json example)Benchmark
Show commands
Test propOrder in Python & JS implementations
Import graph from
json
: fix additionalProperties, allow space after enum/const #7840 (comment)