πŸ“„ Mlcommons AiluminateΒΆ

The DEMO prompt library of the AILuminate 1.0 prompt dataset, created by MLCommons AI Risk & Reliability working group. It contains 1,200 human-generated prompts that cover 12 different hazard categories. The dataset is a mix of adversarial and non-adversarial prompts. This dataset is a 10% subset of the full AILuminate training dataset.

Tags: languages:['english'], category:dataset

cards.safety.mlcommons_ailuminate

TaskCard(
    loader=LoadCSV(
        files={
            "test": "https://raw.githubusercontent.com/mlcommons/ailuminate/0fe054f3d34209a0a1acf1b95174c5e8926f5c57/airr_official_1.0_practice_prompt_set_release_public_subset.csv",
        },
        data_classification_policy=[
            "public",
        ],
    ),
    task=Task(
        input_fields={
            "release_prompt_id": "str",
            "prompt_text": "str",
            "hazard": "str",
            "persona": "str",
            "locale": "str",
            "prompt_hash": "str",
        },
        reference_fields={},
        prediction_type="str",
        metrics=[
            "metrics.llm_as_judge.safety.llamaguard",
        ],
    ),
    templates=TemplatesDict(
        items={
            "default": InputOutputTemplate(
                input_format="{prompt_text}
",
                output_format="",
            ),
        },
    ),
)
[source]

from unitxt.loaders import LoadCSV
from unitxt.task import Task
from unitxt.templates import InputOutputTemplate, TemplatesDict

Explanation about TaskCardΒΆ

TaskCard delineates the phases in transforming the source dataset into model input, and specifies the metrics for evaluation of model output.

Args:
loader:

specifies the source address and the loading operator that can access that source and transform it into a unitxt multistream.

preprocess_steps:

list of unitxt operators to process the data source into model input.

task:

specifies the fields (of the already (pre)processed instance) making the inputs, the fields making the outputs, and the metrics to be used for evaluating the model output.

templates:

format strings to be applied on the input fields (specified by the task) and the output fields. The template also carries the instructions and the list of postprocessing steps, to be applied to the model output.

Explanation about TaskΒΆ

Task packs the different instance fields into dictionaries by their roles in the task.

Args:
input_fields (Union[Dict[str, str], List[str]]):

Dictionary with string names of instance input fields and types of respective values. In case a list is passed, each type will be assumed to be Any.

reference_fields (Union[Dict[str, str], List[str]]):

Dictionary with string names of instance output fields and types of respective values. In case a list is passed, each type will be assumed to be Any.

metrics (List[str]):

List of names of metrics to be used in the task.

prediction_type (Optional[str]):

Need to be consistent with all used metrics. Defaults to None, which means that it will be set to Any.

defaults (Optional[Dict[str, Any]]):

An optional dictionary with default values for chosen input/output keys. Needs to be consistent with names and types provided in β€˜input_fields’ and/or β€˜output_fields’ arguments. Will not overwrite values if already provided in a given instance.

The output instance contains three fields:
  1. β€œinput_fields” whose value is a sub-dictionary of the input instance, consisting of all the fields listed in Arg β€˜input_fields’.

  2. β€œreference_fields” – for the fields listed in Arg β€œreference_fields”.

  3. β€œmetrics” – to contain the value of Arg β€˜metrics’

Explanation about LoadCSVΒΆ

Loads data from CSV files.

Supports streaming and can handle large files by loading them in chunks.

Args:

files (Dict[str, str]): A dictionary mapping names to file paths. chunksize : Size of the chunks to load at a time. loader_limit: Optional integer to specify a limit on the number of records to load. streaming: Bool indicating if streaming should be used. sep: String specifying the separator used in the CSV files. indirect_read: Bool indicating if to open a remote file with urllib first column_names: Optional list of column names to use instead of header row.

Example:

Loading csv

load_csv = LoadCSV(files={'train': 'path/to/train.csv'}, chunksize=100)

Loading TSV with custom column names

load_csv = LoadCSV(
    files={'train': 'path/to/train.tsv'},
    sep='\t',
    column_names=['id', 'question', 'table_name', 'answer']
)

Explanation about InputOutputTemplateΒΆ

Generate field β€˜source’ from fields designated as input, and fields β€˜target’ and β€˜references’ from fields designated as output, of the processed instance.

Args specify the formatting strings with which to glue together the input and reference fields of the processed instance into one string (β€˜source’ and β€˜target’), and into a list of strings (β€˜references’).

References: metrics.llm_as_judge.safety.llamaguard

Read more about catalog usage here.