5 ms·
You can force LLMs to generate valid json by using a context free grammar FWIW
by dartos 3y ago
You can force LLMs to generate valid json by using a context free grammar FWIW
- zuck_vs_musk 3y agoPlease elaborate
- kaiokendev 3y agoMatt Rickard has a good entry level blog post about it, from the angle of regex constraining [0]. Context free grammars follow the same principle, except using a finite state machine to restrict the action space. [0]: https://matt-rickard.com/rellm https://matt-rickard.com/rellm
- dartos 3y agoLook at llama.cpp grammars, lmql, or guidance-ai