Preserving the order of the keys in json-schema-to-grammar by using nlohmann::ordered_json #6215
Closed
4 tasks done
Labels
enhancement
New feature or request
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Feature Description
Using ordered JSONs in json-schema-to-grammar so that the llama.cpp follows the order of the JSON schema.
Motivation
I've been trying the new C++ json-schema-to-grammar from #5978 and I've noticed that there is no prop_order, which is present in the python version, to order the keys of the JSON schema. I think this could be interesting since generating text for some specific keys can improve the text generation of the following keys.
Possible Implementation
An easy solution is replacing the base json
nlohmann::json
withnlohmann::ordered_json
in both files json-schema-to-grammar.h and json-schema-to-grammar.cpp. This will result in JSON that preserves the original order of the keys.The text was updated successfully, but these errors were encountered: