From b61eb9644d64e90123ac805436d95b94b3b4cc3f Mon Sep 17 00:00:00 2001 From: Olivier Chafik Date: Tue, 11 Jun 2024 02:22:57 +0100 Subject: json: refine constraint for whitespace to avoid runaways yet allow pretty print (#7866) --- examples/json_schema_to_grammar.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples/json_schema_to_grammar.py') diff --git a/examples/json_schema_to_grammar.py b/examples/json_schema_to_grammar.py index cd444d01..ab19e20d 100755 --- a/examples/json_schema_to_grammar.py +++ b/examples/json_schema_to_grammar.py @@ -29,9 +29,8 @@ class BuiltinRule: self.content = content self.deps = deps or [] -# whitespace is constrained to a single space char to prevent model "running away" in -# whitespace. Also maybe improves generation quality? -SPACE_RULE = '" "?' +# Constraining spaces to prevent model "running away". +SPACE_RULE = '| " " | "\\n" [ \\t]{0,20}' PRIMITIVE_RULES = { 'boolean' : BuiltinRule('("true" | "false") space', []), -- cgit v1.2.3