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

[FEATURE] Add structured generation from the LLMs #614

Closed
plaguss opened this issue May 7, 2024 · 0 comments · Fixed by #601
Closed

[FEATURE] Add structured generation from the LLMs #614

plaguss opened this issue May 7, 2024 · 0 comments · Fixed by #601
Assignees
Labels
enhancement New feature or request integrations
Milestone

Comments

@plaguss
Copy link
Contributor

plaguss commented May 7, 2024

Is your feature request related to a problem? Please describe.
Integrate outlines to generate structured outputs from LLMs.

Describe the solution you'd like
I would like to generate structured outputs from the LLMs. Ideally, we should generate json as simple as text using other frameworks:

from pydantic import BaseModel

from distilabel.llms import TransformersLLM

# Example from outlines docs
class User(BaseModel):
    name: str
    last_name: str
    id: int

llm = TransformersLLM(
    model="argilla/notus-7b-v1",
    structured_output={"format": "json", "structure": User},
)

llm.load()
result = llm.generate(
    [
        [{"role": "user", "content": "Create a user profile with the fields name, last_name and id"}]
    ],
    max_new_tokens=30
)
print(result)
# [[{"name": "John", "last_name": "Doe", "id": 11}]]

Describe alternatives you've considered
Not generating structured output.

Additional context
We can start with outlines but other candidates are instructor and guidance.

@plaguss plaguss added enhancement New feature or request integrations labels May 7, 2024
@plaguss plaguss added this to the 1.1.0 milestone May 7, 2024
@plaguss plaguss self-assigned this May 7, 2024
@plaguss plaguss linked a pull request May 7, 2024 that will close this issue
4 tasks
@plaguss plaguss closed this as completed May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request integrations
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant