Grammar Constrained Decoding TODO get and run llama cpp input some non-CFG restrictions, using guidance input some CFG restrictions, using guidance regular expressions vs context-free grammars vs regular grammars General way of limiting the output of a language model to a specific grammar or structure, like JSON, specific programming languages, API responses, etc. grammar can be input using BNF (Backus-Naur Form) or just by providing simple 'options' for the model to choose from Grammars Type Grammar Language Automata Type 0 Unrestricted Grammar Recursive Enumerable Language Turing Machine Type 1 Context Sensitive Grammar Context Sensitive Language Linear Bounded Automaton Type 2 Context Free Grammar Context Free Language Pushdown Automaton Type 3 Regular Grammar Regular Language Finite State Automaton References libraries guidance llguidance perf with rust outlines papers guiding llms the right way grammar constrained decoding for structured NLP tasks generating structured outputs from language models articles intro to context-free grammars wiki on context-free grammars python libraries overview logits intro llguidance blogpost datasets JSONSchemaBench yt cfg and chomsky normal form chomsky hierarchy of grammars