Skip to content

LLM generates text that the grammar does not allow #4

@mattiasarro

Description

@mattiasarro

When running the example code, the following exception gets thrown:

UnexpectedCharacters: No terminal matches '"' in the current parser context, at line 1 col 7

The model had generated output {"a": " and the parser did not parse this particular output. Since {"a": " is a valid start of a JSON object, the error is a bit confusing. But playing around with different grammar, prompts and models a bit shows that the model can (and often does) generate text the parser can not parse, which results in lark.lexer.UnexpectedCharacters exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions