https://www.boundaryml.com logo
๐ŸŸก Trouble with BAML parsing output in non-Latin s...
# questions
t
I've tried the method of cutting output tokens by letting the parser do its job (thanks Vaibhav!). But I'm having trouble with BAML parsing output with non-Latin scripts. I get parsing errors for things that are parsed easily in English or Spanish, or parsed if I take away asking to remove quotes in my prompt. Does anyone know any way around this?
v
can you share some examples?
t
Sure. is this good? **Raw LLM Output**:
Copy code
{
  word: ั„ั€ัƒะบั‚,
  translations: [
    {
      translation: fruit,
      partOfSpeech: noun,
      exampleSentence: ะฏ ะปัŽะฑะปัŽ ะตัั‚ัŒ ั„ั€ัƒะบั‚ ะฟะพัะปะต ะพะฑะตะดะฐ.,
      exampleSentenceTranslation: I like to eat fruit after lunch.,
    }
  ],
}
**Parser Output + Error**:
Copy code
{
  "word": "ั„ั€ัƒะบั‚",
  "definitions": []
}
Copy code
[
  {
    "<root>": "error while parsing list",
    "causes": [
      {
        "definitions.0": "Failed while parsing required fields: missing=1, unparsed=0",
        "causes": [
          {
            "definitions.0": "Missing required field: exampleSentenceTranslation",
            "causes": []
          }
        ]
      }
    ]
  }
]
v
and can you share the schema? should
translations
be
definitions
?
t
Yeah . Its aliased to translations. Here is the prompt + schema
v
ah got it
t
Copy code
class Word { 
    word string // test
    definitions Definition[] @alias("translations")
    @@dynamic
}




class Definition {
    definition string @alias("translation") @description(#"
      1 to 6 words
    "#)
    partOfSpeech string
    exampleSentence string
    exampleTranslation string @alias("exampleSentenceTranslation")
}
v
testing now!
t
Thanks for everything you and your team do. It makes building projects a looot easier
v
ok i found the bug, it seems to be the field
exampleSentance
causes some issues for us when its non-asci, no-quotes, and then ends with a
.,
I'll see what i can cook up
> summary from claude! Found it! and it's a real bug on our end. Thanks for the super clean repro ๐Ÿ™ Root cause: our JSON-fixing parser (the thing that lets the LLM skip quotes) had a byte-offset-vs-character-count bug. When it reads an unquoted value and scans ahead for the next ,/}, it was returning the delimiter's byte position but the outer loop treated that as a character count. For ASCII those are identical, so English/Spanish always worked. But multi-byte scripts (Cyrillic, Greek, CJK, etc.) have more bytes than characters, so once an unquoted value got long enough the parser over-skipped and ate the front of the next field's key โ€” e.g. partOfSpeech became peech, which then failed to match, so the whole object got dropped and you got definitions: []. That's also why it looked tied to "ends with .," and quotes: it wasn't the period at all โ€” it was the unquoted non-Latin value crossing a length threshold (~20 bytes). Quoting the value sidesteps the unquoted-scanning path entirely, which is why removing the "no quotes" instruction made it work. Fix: one line โ€” the scanner now counts characters instead of bytes. Verified against your exact output plus a matrix of Cyrillic/Greek/ASCII cases; full parser suite (594 tests) green. PR here: https://github.com/BoundaryML/baml/pull/3818 As a workaround until it ships, dropping the "Do not put quotes around strings" line from your prompt avoids it. ๐Ÿ‘