Skip to content

Custom Prefixes for data column and few shot column for prompt #45

@HallerPatrick

Description

@HallerPatrick

Currently generate_data_for_columnand fewshot_example_columns are used as the prefixs for the prompt.

E.g.:

from datasets import Dataset
from ai_dataset_generator.prompts import BasePrompt

fewshot_examples = Dataset.from_dict({
    "text": ["This movie is great!", "This movie is bad!"],
    "label": ["positive", "negative"]
})

prompt_template = BasePrompt(
    task_description="Annotate movie reviews as either: {label_options}",
    label_options=["positive", "negative"],
    generate_data_for_column="label",
    fewshot_example_columns="text",
)

Has Output:

Annotate movie reviews as either: positive, negative

text: This movie is great!
label: positive

text: This movie is bad!
label: negative

text: {text}
label: 

With text: and label: as the prefixes.

Proposal/Motivation

What if I use a custom fine-tuned model, that does not work well with textand label as prefixes in the prompt, but was trained with sentence and prediction.

For more flexibility, those prefixes should be optionally configurable. For example:

from datasets import Dataset
from ai_dataset_generator.prompts import BasePrompt

fewshot_examples = Dataset.from_dict({
    "text": ["This movie is great!", "This movie is bad!"],
    "label": ["positive", "negative"]
})

prompt_template = BasePrompt(
    task_description="Annotate movie reviews as either: {label_options}",
    label_options=["positive", "negative"],
    generate_data_for_column=("label", "sentence"),  # Second tuple item contains the new prefix string
    fewshot_example_columns=("text", "prediction"),  # Second tuple item contains the new prefix string
)

Has Output:

Annotate movie reviews as either: positive, negative

sentence: This movie is great!
prediction: positive

sentence: This movie is bad!
prediction: negative

sentence: {text}
prediction: 

The default behaviour could stay the same and the column name is used as the prefix. If it is a tuple (or other structure) then the second item is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions