π Both Games Gpt 4 JudgeΒΆ
cards.arena_hard.response_assessment.pairwise_comparative_rating.both_games_gpt_4_judge
TaskCard(
loader=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",
},
data_classification_policy=[
"public",
],
),
preprocess_steps=[
"operators.arena_hard_hf_space_processing_steps",
DuplicateSplit(
split="test",
to_split="game_2",
),
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",
],
),
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",
],
),
MergeStreams(
streams_to_merge=[
"test",
"game_2",
],
new_stream_name="test",
add_origin_stream_name=False,
),
DeleteSplits(
splits=[
"game_2",
],
),
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]from unitxt.loaders import LoadFromHFSpace
from unitxt.operators import MapInstanceValues, MergeStreams, Rename
from unitxt.stream_operators import DeleteSplits, DuplicateSplit
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 LoadFromHFSpaceΒΆ
Used to load data from HuggingFace Spaces lazily.
- 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.
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 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.
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 that1was 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, usestrict=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 DuplicateSplitΒΆ
Operator which duplicate a split.
- Attributes:
split (str): The split to duplicate from the stream. to_split (str): The duplicate splitβs 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.