Comment Comment by nautilus50 +1, llama.cpp has a --grammar parameter which you can pass a BNF style grammar file to constrain generation. It can be used in Python llama.cpp wrapperhttps://til.simonwillison.net/llms/llama-cpp-python-grammars parent nautilus50 1 month ago
https://til.simonwillison.net/llms/llama-cpp-python-grammars