Skip to content
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

Add sample for structured "imagination" #1

Open
leloykun opened this issue Jul 16, 2024 · 0 comments
Open

Add sample for structured "imagination" #1

leloykun opened this issue Jul 16, 2024 · 0 comments

Comments

@leloykun
Copy link
Owner

"Structured Imagination" is a placeholder name for controlling how many "draft" tokens and "imagination" tokens the model generates first before generating the final answer.

Sample json schema:

json_schema = {
    "name": "Fruit Generator",
    "description": "A tool that generates details about a fruit with text and images in one go!",
    "type": "object",
    "properties": {
        "imagination" : {
            "type": "image",
            "maxLength": 100,
        },
        "draft_reasoning": {
            "type": "string",
            "pattern": "[a-zA-Z0-9]{1,100}",
        },
        "imagination_2" : {
            "type": "image",
            "maxLength": 100,
        },
        "draft_reasoning_2": {
            "type": "string",
            "pattern": "[a-zA-Z0-9]{1,100}",
        },
        "cat_dog": {
            "type": "image",
        }
    },
    "required": ["imagination", "draft_reasoning", "imagination_2", "draft_reasoning_2", "cat_dog"],
}

Equivalent regex expression:

\{[ ]?"imagination"[ ]?:[ ]?"<image>{,100}"[ ]?,[ ]?"draft_reasoning"[ ]?:[ ]?("[a-zA-Z0-9]{1,100}")[ ]?,[ ]?"imagination_2"[ ]?:[ ]?"<image>{,100}"[ ]?,[ ]?"draft_reasoning_2"[ ]?:[ ]?("[a-zA-Z0-9]{1,100}")[ ]?,[ ]?"cat_dog"[ ]?:[ ]?"<image>{1024,1024}"[ ]?\}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant