Conversation
…int_pattern / get_str_pattern
|
This looks fantastic - are there pieces in this PR that can be merged quickly? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The repetition problem of language models combined with patterns allowing for infinite-length fields results in broken JSON Schema outputs.
This was addressed previously for infinite whitespaces issues by setting a safe whitespace pattern as the default. In this PR, the safety of whitespaces is extended to Integer and String patterns.
Behavior
json_schema.to_regexnow includes an kwargsafe_subset=True.safe_subset=Falser"[\n\t ]*"safe_subset=True(default)r"[ ]?"Fixes
Safe Integer
Safe String
non_strictmode)promptsUsing Chat Templates inSequenceGeneratorAdapterdottxt-ai/outlines#987Further Work
Important: Low quality outputs are often caused by not applying a chat template. All examples should include chat templates, or user response quality will suffer. Format
promptsUsing Chat Templates inSequenceGeneratorAdapterdottxt-ai/outlines#987Make code more failsafe: Add a non_strict mode to deal with JSONDecodeError errors dottxt-ai/outlines#985
numberhas nosafe_subsetimplementation. Its' likely the only unsafe primitive remaining without one. There aren't any open issues for an error caused by number, however.