Skip to content

Commit 3b5f777

Browse files
authored
Add grammar and grammar_type fields to GenerationConfig (#19729)
Differential Revision: D106007312 Pull Request resolved: #19729
1 parent c5e0a03 commit 3b5f777

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

examples/qualcomm/oss_scripts/llama/qnn_llama_runner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ void start_runner(
245245
};
246246
executorch::extension::llm::GenerationConfig config{
247247
true,
248+
"",
249+
"",
248250
false,
249251
-1,
250252
false,

extension/llm/runner/irunner.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ struct GenerationConfig {
3333
// Whether to echo the input prompt in the output
3434
bool echo = true;
3535

36+
// Grammar definition for constrained decoding (e.g. a JSON schema, regex,
37+
// Lark CFG, or GBNF grammar). Empty string means no constraint.
38+
std::string grammar;
39+
40+
// Grammar format: "json_schema", "regex", "lark", or "gbnf".
41+
// Only used when grammar is non-empty.
42+
std::string grammar_type;
43+
3644
// Whether to ignore EOS token and continue generating until max_new_tokens
3745
bool ignore_eos = false;
3846

0 commit comments

Comments
 (0)