Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Generation from partially done JSON/List #689

Closed
isamu-isozaki opened this issue Feb 20, 2024 · 1 comment
Closed

Generation from partially done JSON/List #689

isamu-isozaki opened this issue Feb 20, 2024 · 1 comment

Comments

@isamu-isozaki
Copy link
Contributor

isamu-isozaki commented Feb 20, 2024

What I want is to complete a list of BaseTasks given couple BaseTasks are already defined like [BaseTask1, BaseTask2
and I want the model to complete the list. The schema is below

class CompletionStatus(str, Enum):
    todo = 'todo'
    done = 'done'
    inprogress = "inprogress"

class BaseTask(BaseModel):
    status: CompletionStatus
    task_description: constr(max_length=50)
@isamu-isozaki isamu-isozaki changed the title Generation from partially done JSON Generation from partially done JSON/List Feb 20, 2024
@rlouf rlouf added enhancement structured generation Linked to structured generation labels Feb 21, 2024
@rlouf
Copy link
Member

rlouf commented Feb 21, 2024

If I understand correctly you can already do this, and it could be handled more elegantly once #667 is implemented. For instance:

gen_choice = generate.choice(model, [", ", "]"])
gen_task = generate.json(model, BaseTask)

prompt = "[BaseTask1, BaseTask"
while True:
    result = gen_choice(prompt)
    if result == "]":
        return prompt + "]"
    else:
        prompt += ", "
        result = gen_task(prompt)
        prompt += result

@rlouf rlouf removed enhancement structured generation Linked to structured generation labels Feb 21, 2024
@outlines-dev outlines-dev locked and limited conversation to collaborators Feb 21, 2024
@rlouf rlouf converted this issue into discussion #694 Feb 21, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants