Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Blacklist control characters in JSON string grammars #1259

Copy link
Copy link
Closed
@jndiogo

Description

@jndiogo
Issue body actions

This llama.cpp PR fixed a random problem that I've observed in the past but never been able to reproduce:

ggml-org/llama.cpp#5888

The problem happens because the string definition in the JSON grammar doesn't exclude emitting raw \n, \r, etc. A model can thus produce a string split into multiple lines, which is not valid JSON.

File llama_cpp/llama_grammar.py needs the string grammar definition fixed in several places:

  • At the JSON_GBNF definition and others that have a string rule, like JSON_ARR_GBNF, etc.
  • At the string definition inside PRIMITIVE_RULES.

It's a single line change in the above PR.

Regards

abetlen

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.