-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move JSON grammar -> regex grammar conversion to the router #2772
Conversation
Awesome 🔥 I had a quick look and it seems to be good 👍 I haven't run it locally thou (yet). For reference, this was an error we couldn't catch before, that we now should be able to capture: #2280 |
If you can update the snapshots this looks good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! great improvement!
*just need some small changes to make CI happy
This change moves the JSON grammar -> regex grammar conversion to the router by adding a dependency on the `outlines-core` Rust crate. In contrast to the Python implementation, the conversions are not LRU-cached since they seem to be fast enough: simple schema time: [5.8293 µs 5.8307 µs 5.8320 µs] change: [-13.166% -12.884% -12.641%] (p = 0.00 < 0.05) Performance has improved. complex schema time: [14.875 µs 14.881 µs 14.887 µs] change: [-2.1637% -1.9914% -1.7852%] (p = 0.00 < 0.05) Performance has improved. Using the schemas from: https://github.com/dottxt-ai/outlines-core/blob/main/benchmarks/bench_json_schema.py
Doing so will brake the build (probably do to a diff in the crate2nix machinery).
2792e8d
to
d5225d4
Compare
What does this PR do?
This change moves the JSON grammar -> regex grammar conversion to the router by adding a dependency on the
outlines-core
Rust crate. In contrast to the Python implementation, the conversions are not LRU-cached since they seem to be fast enough:Using the schemas from:
https://github.com/dottxt-ai/outlines-core/blob/main/benchmarks/bench_json_schema.py
Some additional remarks:
JSON
type from the v3 protobuf for compatibility. Instead, an error emitted and the grammar is ignored..*
grammar.outlines-core
is not in crates.io yet, @ErikKaum recommended to use the latest version from Git.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.