πŸ“„ English Gpt 4 0314 ReferenceΒΆ

Note

ID: cards.arena_hard.generation.english_gpt_4_0314_reference | Type: TaskCard

{
    "__type__": "task_card",
    "loader": {
        "__type__": "load_from_hf_space",
        "data_files": {
            "model_answer": "data/arena-hard-v0.1/model_answer/gpt-4-0314.jsonl",
            "questions": "data/arena-hard-v0.1/question.jsonl"
        },
        "revision": "03b91ca",
        "space_name": "lmsys/arena-hard-browser"
    },
    "preprocess_steps": [
        {
            "__type__": "rename_fields",
            "apply_to_streams": [
                "questions"
            ],
            "field_to_field": {
                "cluster": "group"
            }
        },
        {
            "__type__": "copy",
            "apply_to_streams": [
                "questions"
            ],
            "field_to_field": {
                "turns/0/content": "model_input"
            }
        },
        {
            "__type__": "set",
            "apply_to_streams": [
                "questions"
            ],
            "fields": {
                "reference_model": "gpt-4-0314"
            }
        },
        {
            "__type__": "copy",
            "apply_to_streams": [
                "model_answer"
            ],
            "field_to_field": {
                "choices/0/turns/0/content": "reference_model_output",
                "choices/0/turns/0/token_len": "reference_model_output_token_len"
            }
        },
        {
            "__type__": "rename_fields",
            "apply_to_streams": [
                "model_answer"
            ],
            "field_to_field": {
                "model_id": "reference_model"
            }
        },
        {
            "__type__": "apply",
            "_argv": [
                "reference_model"
            ],
            "apply_to_streams": [
                "model_answer"
            ],
            "function": "str.lower",
            "to_field": "reference_model"
        },
        {
            "__type__": "join_streams",
            "how": "inner",
            "left_stream": "questions",
            "new_stream_name": "test",
            "on": [
                "question_id",
                "reference_model"
            ],
            "right_stream": "model_answer"
        },
        {
            "__type__": "delete_splits",
            "splits": [
                "questions",
                "model_answer"
            ]
        },
        {
            "__type__": "select_fields",
            "fields": [
                "question_id",
                "category",
                "model_input",
                "reference_model",
                "reference_model_output"
            ]
        },
        {
            "__type__": "rename_fields",
            "field_to_field": {
                "category": "group",
                "model_input": "input",
                "reference_model_output": "output"
            }
        },
        {
            "__type__": "set",
            "fields": {
                "type_of_input": "prompt",
                "type_of_output": "answer"
            }
        }
    ],
    "task": "tasks.generation",
    "templates": [
        "templates.empty"
    ]
}

Explanation about TaskCardΒΆ

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

Attributes:

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 a 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 LoadFromHFSpaceΒΆ

Used to load data from Huggingface spaces.

Loaders firstly tries to download all files specified in the β€˜data_files’ parameter from the given space and then reads them as a Huggingface dataset.

Args:

space_name (str): Name of the Huggingface space to be accessed to. data_files (str | Sequence[str] | Mapping[str, str | Sequence[str]]): Relative

paths to files within a given repository. If given as a mapping, paths should be values, while keys should represent the type of respective files (training, testing etc.).

path (str, optional): Absolute path to a directory where data should be downloaded to. revision (str, optional): ID of a Git branch or commit to be used. By default, it is

set to None, thus data is downloaded from the main branch of the accessed repository.

use_token (bool, optional): Whether token used for authentication when accessing

the Huggingface space - if necessary - should be read from the Huggingface config folder.

token_env (str, optional): Key of an env variable which value will be used for

authentication when accessing the Huggingface space - if necessary.

Example:

Loading from Huggingface Space

loader = LoadFromHFSpace(
    space_name="lmsys/mt-bench",
    data_files={
        "train": [
            "data/mt_bench/model_answer/gpt-3.5-turbo.jsonl",
            "data/mt_bench/model_answer/gpt-4.jsonl",
        ],
        "test": "data/mt_bench/model_answer/tulu-30b.jsonl",
    },
)

Explanation about JoinStreamsΒΆ

Join multiple streams into a single stream.

Args:

left_stream (str): The stream that will be considered the β€œleft” in the join operations. right_stream (str): The stream that will be considered the β€œright” in the join operations. how (Literal[β€œleft”, β€œright”, β€œinner”, β€œouter”, β€œcross”]): The type of join to be performed. on (Optional[List[str]]): Column names to join on. These must be found in both streams. left_on (Optional[List[str]]): Column names to join on in the left stream. right_on (Optional[List[str]]): Column names to join on in the right streasm. new_stream_name (str): The name of the new stream resulting from the merge.

Examples:

JoinStreams(left_stream = β€œquestions”, right_stream = β€œanswers”, how=”inner”, on=”question_id”, new_stream_name=”question_with_answers” ) Join the β€˜question’ and β€˜answer’ stream based on the β€˜question_id’ field using inner join, resulting with a new stream named β€œquestion_with_answers”. JoinStreams(left_stream = β€œquestions”, right_stream = β€œanswers”, how=”inner”, on_left=”question_id”, on_right=”question” new_stream_name=”question_with_answers” ) Join the β€˜question’ and β€˜answer’ stream based on the β€˜question_id’ field in the left stream and the β€˜question’ field in the right stream, using inner join, resulting with a new stream named β€œquestion_with_answers”. This is suitable when the fields have different labels across the streams.

Explanation about CopyΒΆ

Copies values from specified fields to specified fields.

Args (of parent class):

field_to_field (Union[List[List], Dict[str, str]]): A list of lists, where each sublist contains the source field and the destination field, or a dictionary mapping source fields to destination fields.

Examples:

An input instance {β€œa”: 2, β€œb”: 3}, when processed by Copy(field_to_field={β€œa”: β€œb”} would yield {β€œa”: 2, β€œb”: 2}, and when processed by Copy(field_to_field={β€œa”: β€œc”} would yield {β€œa”: 2, β€œb”: 3, β€œc”: 2}

with field names containing / , we can also copy inside the field: Copy(field=”a/0”,to_field=”a”) would process instance {β€œa”: [1, 3]} into {β€œa”: 1}

Explanation about DeleteSplitsΒΆ

Operator which delete splits in stream.

Attributes:

splits (List[str]): The splits to delete from the stream.

Explanation about SetΒΆ

Adds specified fields to each instance in a given stream or all streams (default) If fields exist, updates them.

Args:
fields (Dict[str, object]): The fields to add to each instance.

Use β€˜/’ to access inner fields

use_deepcopy (bool) : Deep copy the input value to avoid later modifications

Examples:

# Add a β€˜classes’ field with a value of a list β€œpositive” and β€œnegative” to all streams Set(fields={β€œclasses”: [β€œpositive”,”negatives”]})

# Add a β€˜start’ field under the β€˜span’ field with a value of 0 to all streams Set(fields={β€œspan/start”: 0}

# Add a β€˜classes’ field with a value of a list β€œpositive” and β€œnegative” to β€˜train’ stream Set(fields={β€œclasses”: [β€œpositive”,”negatives”], apply_to_stream=[β€œtrain”]})

# Add a β€˜classes’ field on a given list, prevent modification of original list # from changing the instance. Set(fields={β€œclasses”: alist}), use_deepcopy=True) # if now alist is modified, still the instances remain intact.

Explanation about RenameFieldsΒΆ

Renames fields.

Move value from one field to another, potentially, if field name contains a /, from one branch into another. Remove the from field, potentially part of it in case of / in from_field.

Examples:

RenameFields(field_to_field={β€œb”: β€œc”}) will change inputs [{β€œa”: 1, β€œb”: 2}, {β€œa”: 2, β€œb”: 3}] to [{β€œa”: 1, β€œc”: 2}, {β€œa”: 2, β€œc”: 3}]

RenameFields(field_to_field={β€œb”: β€œc/d”}) will change inputs [{β€œa”: 1, β€œb”: 2}, {β€œa”: 2, β€œb”: 3}] to [{β€œa”: 1, β€œc”: {β€œd”: 2}}, {β€œa”: 2, β€œc”: {β€œd”: 3}}]

RenameFields(field_to_field={β€œb”: β€œb/d”}) will change inputs [{β€œa”: 1, β€œb”: 2}, {β€œa”: 2, β€œb”: 3}] to [{β€œa”: 1, β€œb”: {β€œd”: 2}}, {β€œa”: 2, β€œb”: {β€œd”: 3}}]

RenameFields(field_to_field={β€œb/c/e”: β€œb/d”}) will change inputs [{β€œa”: 1, β€œb”: {β€œc”: {β€œe”: 2, β€œf”: 20}}}] to [{β€œa”: 1, β€œb”: {β€œc”: {β€œf”: 20}, β€œd”: 2}}]

Explanation about ApplyΒΆ

A class used to apply a python function and store the result in a field.

Args:

function (str): name of function. to_field (str): the field to store the result additional arguments are field names passed to the function

Examples: Store in field β€œb” the uppercase string of the value in field β€œa” Apply(β€œa”, function=str.upper, to_field=”b”)

Dump the json representation of field β€œt” and store back in the same field. Apply(β€œt”, function=json.dumps, to_field=”t”)

Set the time in a field β€˜b’. Apply(function=time.time, to_field=”b”)

Explanation about SelectFieldsΒΆ

Keep only specified fields from each instance in a stream.

Args:

fields (List[str]): The fields to keep from each instance.

References: tasks.generation, templates.empty

Read more about catalog usage here.