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 default structured output for GenerateSentencePair task #868

Merged
merged 7 commits into from
Aug 9, 2024

Conversation

plaguss
Copy link
Contributor

@plaguss plaguss commented Aug 8, 2024

Description

Adds a default structured output for GenerateSentencePair, it can be set from the Task and will prepare the LLM for it internally.

from distilabel.steps.tasks import GenerateSentencePair
from distilabel.llms import InferenceEndpointsLLM

generate_sentence_pair = GenerateSentencePair(
    triplet=True, # `False` to generate only positive
    action="query",
    llm=...,
#    llm=InferenceEndpointsLLM(
#        model_id="meta-llama/Meta-Llama-3.1-70B-Instruct",
#    ),
    use_default_structured_output=True,
    input_batch_size=10,
)

Depending of the LLM will use a provider for the structured outputs. For example with InferenceEndpointsLLM it will use outlines to generate a dict of the form: {"positive": ...} or {"positive": ..., "negative": ...} that will be easier to parse.

It also puts in place a mechanism to define a default structured output for every Task that may require it.

Closes #867

@plaguss plaguss self-assigned this Aug 8, 2024
@plaguss plaguss requested a review from gabrielmbmb August 8, 2024 11:07
@plaguss plaguss added this to the 1.4.0 milestone Aug 8, 2024
@plaguss plaguss added the enhancement New feature or request label Aug 8, 2024
Copy link

github-actions bot commented Aug 8, 2024

Documentation for this PR has been built. You can view it at: https://distilabel.argilla.io/pr-868/

@plaguss plaguss marked this pull request as ready for review August 8, 2024 14:19
Copy link
Member

@gabrielmbmb gabrielmbmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

src/distilabel/steps/tasks/sentence_transformers.py Outdated Show resolved Hide resolved
src/distilabel/steps/tasks/base.py Outdated Show resolved Hide resolved
src/distilabel/steps/tasks/base.py Outdated Show resolved Hide resolved
@plaguss plaguss linked an issue Aug 9, 2024 that may be closed by this pull request
@plaguss plaguss merged commit 5e5e7c3 into develop Aug 9, 2024
1 of 6 checks passed
@plaguss plaguss deleted the set_structured_output branch August 9, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] GenerateSentencePair predefined structured output
2 participants