News for hackers. Stuff that matters.
Re:Llama: Add Grammar-Based Sampling by pshc on Friday July 21, 2023 @06:39PM (#36820922)
I don't think this is correct; previously you could already control output by reading tokens one at a time from the LLM until you hit a stop character.

My take from the grammar-based sampling PR is that you ask llama.cpp to constrain the next output token, to a restricted set of possible tokens, using the grammar.

Re:Llama: Add Grammar-Based Sampling by simonw on Friday July 21, 2023 @06:42PM (#36820952)
Right, which is the same idea - it's just that the code in llama.cpp is running your grammar as part of its token generation decisions as opposed to pausing and waiting for your other code to pick the next token.

(I'm trying for a very high level explanation here.)

Re:Llama: Add Grammar-Based Sampling by swyx on Saturday July 22, 2023 @04:53AM (#36824581)
you could also always specify the logit bias parameter in openai apis
Re:Llama: Add Grammar-Based Sampling by pshc on Saturday July 22, 2023 @07:23AM (#36825307)
That's true, and one can bias logits in llama.cpp and friends too, but those are global biases that affect the entire output rather than being specified per-token. Uploading a grammar or a wasm binary to the inference engine does seem more expressive.