-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Comparing changes
Open a pull request
base repository: ggml-org/llama.cpp
base: master
head repository: ochafik/llama.cpp
compare: token-aware-grammars-impl
- 6 commits
- 16 files changed
- 2 contributors
Commits on Dec 19, 2025
-
chat: add FunctionGemma tool call support
Implements tool call handling for FunctionGemma models which use a unique format: <start_function_call>call:name{key:<escape>val<escape>}<end_function_call> Changes: - Add COMMON_CHAT_FORMAT_FUNCTION_GEMMA enum - Implement grammar builder for FunctionGemma format - Implement parser for FunctionGemma tool calls - Add template detection for <start_function_call> markers - Add google-functiongemma.jinja template - Add unit tests and e2e test entries 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>Configuration menu - View commit details
-
Copy full SHA for 622acae - Browse repository at this point
Copy the full SHA 622acaeView commit details -
fix(functiongemma): parser and template bug fixes
Parser: Use state machine to find closing brace, properly handling `}` characters inside `<escape>` delimiters. Previously used [^}]* regex which would break on values like `{key:<escape>foo}bar<escape>}`. Template: Output tool calls in native FunctionGemma format `{key:<escape>value<escape>}` instead of JSON format `{"key":"value"}`. This ensures the model sees correct examples in conversation history. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>Configuration menu - View commit details
-
Copy full SHA for a424920 - Browse repository at this point
Copy the full SHA a424920View commit details -
peg-parser: add preserved() for token-aware matching
Add common_peg_preserved_parser type that matches preserved tokens (like <tool_call>, <escape>) at the token level when token info is available, with graceful fallback to text matching. New features: - common_peg_token_span struct for token boundary info - common_peg_parse_context extended with optional token spans - preserved(literal, token_id) builder method - Token-aware matching: if token_id set and context has tokens, match by token ID; otherwise fall back to text This is the infrastructure for token-aware grammars as described in docs/development/token-aware-grammars.md. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Configuration menu - View commit details
-
Copy full SHA for e47e909 - Browse repository at this point
Copy the full SHA e47e909View commit details -
peg-parser: add tests for preserved() token-aware matching
Add comprehensive tests for the preserved parser: - Text fallback (success, fail, partial) - Token-aware matching when token info available - Token mismatch detection - Sequence with preserved tokens - Qwen3-Coder-like parser demo (with and without token info) The tests demonstrate how preserved() enables parsers to match special tokens at the token level when token boundary info is available, falling back to text matching otherwise. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Configuration menu - View commit details
-
Copy full SHA for 4bb89a0 - Browse repository at this point
Copy the full SHA 4bb89a0View commit details -
peg-parser: rename preserved() to token(), resolve token IDs at runtime
- Rename common_peg_preserved_parser to common_peg_token_parser - Rename preserved() method to token() for cleaner API - Token IDs are now resolved at parse time from context's token_ids map instead of being hardcoded in the parser definition - Add token_ids map to common_peg_parse_context for runtime resolution - Update FunctionGemma parser to use new token() API - Wire up FunctionGemma PEG parser (COMMON_CHAT_FORMAT_PEG_FUNCTION_GEMMA) - Update all tests to use new token() method and provide token_ids map 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Configuration menu - View commit details
-
Copy full SHA for feab6dc - Browse repository at this point
Copy the full SHA feab6dcView commit details
Commits on Dec 20, 2025
-
grammar: add @"..." token-aware literal syntax
Add LLAMA_GRETYPE_TOKEN_LITERAL for token-aware grammar matching: - Matches by token ID when literal resolves to single token - Falls back to character-by-character matching otherwise Also adds until_token() to PEG parser and updates to_gbnf() to emit @"..." syntax for token() primitives, enabling token-aware constrained decoding in generated grammars. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Configuration menu - View commit details
-
Copy full SHA for 005780d - Browse repository at this point
Copy the full SHA 005780dView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff master...token-aware-grammars-impl