πŸ“„ Both Games Gpt 4 JudgeΒΆ

cards.arena_hard.response_assessment.pairwise_comparative_rating.both_games_gpt_4_judge

type: TaskCard
loader: 
  type: LoadFromHFSpace
  space_name: lmsys/arena-hard-browser
  revision: 03b91ca
  data_files: 
    questions: data/arena-hard-v0.1/question.jsonl
    model_answer: data/arena-hard-v0.1/model_answer/*.jsonl
    judgment: data/arena-hard-v0.1/model_judgment/gpt-4-1106-preview/*.jsonl
preprocess_steps: 
  - operators.arena_hard_hf_space_processing_steps
  - type: DuplicateSplit
    split: test
    to_split: game_2
  - type: Rename
    field_to_field: 
      model_input: question
      model_1_output: answer_a
      model_2_output: answer_b
      score_model_1_ordered_first: answer_a_preference
      category: group
      model_1: model_a
      model_2: model_b
    apply_to_streams: 
      - test
  - type: Rename
    field_to_field: 
      model_input: question
      model_1_output: answer_b
      model_2_output: answer_a
      score_model_2_ordered_first: answer_a_preference
      category: group
      model_1: model_b
      model_2: model_a
    apply_to_streams: 
      - game_2
  - type: MergeStreams
    streams_to_merge: 
      - test
      - game_2
    new_stream_name: test
    add_origin_stream_name: False
  - type: DeleteSplits
    splits: 
      - game_2
  - type: MapInstanceValues
    mappers: 
      answer_a_preference: 
        A=B: 0
        A>B: 1
        A>>B: 3
        B>A: -1
        B>>A: -3
task: tasks.response_assessment.pairwise_comparative_rating.single_turn
templates: 
  - templates.response_assessment.pairwise_comparative_rating.arena_hard
  - templates.response_assessment.pairwise_comparative_rating.arena_hard_with_shuffling
[source]

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.

default_template:

a default template for tasks with very specific task dataset specific template

Explanation about DuplicateSplitΒΆ

Operator which duplicate a split.

Attributes:

split (str): The split to duplicate from the stream. to_split (str): The duplicate split’s name.

Explanation about RenameΒΆ

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:

Rename(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}]

Rename(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}}]

Rename(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}}]

Rename(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 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.

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.

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 a token is used for authentication when accessing the HuggingFace Space. If necessary, the token is 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 a 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 DeleteSplitsΒΆ

Operator which delete splits in stream.

Attributes:

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

Explanation about MapInstanceValuesΒΆ

A class used to map instance values into other values.

This class is a type of InstanceOperator, it maps values of instances in a stream using predefined mappers.

Args:
mappers (Dict[str, Dict[str, Any]]):

The mappers to use for mapping instance values. Keys are the names of the fields to undergo mapping, and values are dictionaries that define the mapping from old values to new values. Note that mapped values are defined by their string representation, so mapped values are converted to strings before being looked up in the mappers.

strict (bool):

If True, the mapping is applied strictly. That means if a value does not exist in the mapper, it will raise a KeyError. If False, values that are not present in the mapper are kept as they are.

process_every_value (bool):

If True, all fields to be mapped should be lists, and the mapping is to be applied to their individual elements. If False, mapping is only applied to a field containing a single value.

Examples:

MapInstanceValues(mappers={"a": {"1": "hi", "2": "bye"}}) replaces "1" with "hi" and "2" with "bye" in field "a" in all instances of all streams: instance {"a": 1, "b": 2} becomes {"a": "hi", "b": 2}. Note that the value of "b" remained intact, since field-name "b" does not participate in the mappers, and that 1 was casted to "1" before looked up in the mapper of "a".

MapInstanceValues(mappers={"a": {"1": "hi", "2": "bye"}}, process_every_value=True): Assuming field "a" is a list of values, potentially including "1"-s and "2"-s, this replaces each such "1" with "hi" and "2" – with "bye" in all instances of all streams: instance {"a": ["1", "2"], "b": 2} becomes {"a": ["hi", "bye"], "b": 2}.

MapInstanceValues(mappers={"a": {"1": "hi", "2": "bye"}}, strict=True): To ensure that all values of field "a" are mapped in every instance, use strict=True. Input instance {"a":"3", "b": 2} will raise an exception per the above call, because "3" is not a key in the mapper of "a".

MapInstanceValues(mappers={"a": {str([1,2,3,4]): "All", str([]): "None"}}, strict=True) replaces a list [1,2,3,4] with the string "All" and an empty list by string "None".

Explanation about MergeStreamsΒΆ

Merges multiple streams into a single stream.

Args:

new_stream_name (str): The name of the new stream resulting from the merge. add_origin_stream_name (bool): Whether to add the origin stream name to each instance. origin_stream_name_field_name (str): The field name for the origin stream name.

References: templates.response_assessment.pairwise_comparative_rating.arena_hard_with_shuffling, templates.response_assessment.pairwise_comparative_rating.arena_hard, tasks.response_assessment.pairwise_comparative_rating.single_turn, operators.arena_hard_hf_space_processing_steps

Read more about catalog usage here.