noamgat / lm-format-enforcer

Enforce the output format (JSON Schema, Regex etc) of a language model
MIT License
994 stars 45 forks source link

prefixItems keyword is not constraining output types #111

Open cikkle opened 4 weeks ago

cikkle commented 4 weeks ago

See this issue.

I'm using lm-format-enforcer through tabbyAPI's streaming completions API and it doesn't appear to be following type constraints given using the prefixItems keyword. I reported this with them first on the oft chance the problem might lie outside the library somehow, but they didn't find it likely.

Verbatim from the other incident:

To Reproduce This is an example schema I tested:

 { 
     "type": "array",
     "prefixItems": [
         { "const": "FIXED" },
         { "type": "number" },
         { "type": "string" }     
     ],
     "minItems": 3,
     "maxItems": 3
}

On different attempts, I get back things like:

[12185635797, 56, "Hello"] [20020715, 13, 2002] ["hello", 13, "World"] [1.14, 1.13,1.12]

Expected behavior The output should follow the constraints of the prefixItems keyword in the schema, e.g.:

[ "FIXED", 3245.34, "hello"]

noamgat commented 4 weeks ago

The library does not support the prefixItems feature yet. I'm leaving this issue open as a feature request, please vote on it using thumbsup responses on the first message!

On Thu, Jun 6, 2024 at 12:09 AM cikkle @.***> wrote:

See this issue https://github.com/theroyallab/tabbyAPI/issues/131.

I'm using lm-format-enforcer through tabbyAPI's streaming completions API and it doesn't appear to be following type constraints given using the prefixItems keyword. I reported this with them first on the oft chance the problem might lie outside the library somehow, but they didn't find it likely.

Verbatim from the other incident:

To Reproduce This is an example schema I tested:

{ "type": "array", "prefixItems": [ { "const": "FIXED" }, { "type": "number" }, { "type": "string" } ], "minItems": 3, "maxItems": 3 }

On different attempts, I get back things like:

[12185635797, 56, "Hello"] [20020715, 13, 2002] ["hello", 13, "World"] [1.14, 1.13,1.12]

Expected behavior The output should follow the constraints of the prefixItems keyword in the schema, e.g.:

[ "FIXED", 3245.34, "hello"]

— Reply to this email directly, view it on GitHub https://github.com/noamgat/lm-format-enforcer/issues/111, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFA2CPN7LMJJ3GUY3DYVLZF546ZAVCNFSM6AAAAABI3POXZKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTMOBTHEYDSNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>