common : replace wrap_for_generation with a prefix convenience function + gpt-oss fixes#20912
Merged
aldehir merged 1 commit intoggml-org:masterfrom Mar 24, 2026
Merged
Conversation
…on and fix gpt-oss
Member
|
Dunno, the creator of the PEG parser said that it's not a good idea to add more helper builders ;) |
Contributor
Author
|
I meant inside the core peg parser so it's still useful for general parsing tasks. Inside the chat builder, anything goes! Sorry for not making that distinction. I do prefer more composable patterns though, for example we're just matching a prefix here. |
Member
|
Aight, might want to take this out of draft :) |
Contributor
Author
|
Wanted to run through a few models before removing out of draft, ministral-3 thinks forever. |
Member
|
BTW you might want to take a look at #20844 - I scrapped the previous approach and did the regexp generator for the full pattern, but also expanded the tests to check whether the grammar is actually triggered. |
pwilkin
approved these changes
Mar 23, 2026
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
…on and fix gpt-oss (ggml-org#20912)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Remove
wrap_for_generationfunction and replace with aprefix()parser that generates a literal up to a given delimiter.Clean up gpt-oss and fix required tool calling. Injecting the generation prompt greatly simplifies the gpt-oss parser rules. This assumes
<|start|>assistantis always a prefix ofgeneration_prompt, which is a reasonable assumption. It will work even if users append extra tokens, i.e.<|start|>assistant<|channel|>analysis<|message|>I am thinking of chocolate<|end|>.Requirements
cc @pwilkin