๐ Rating Hf Space Processing Stepsยถ
operators.mt_bench.rating_hf_space_processing_steps
type: SequentialOperator
steps:
- type: Rename
field_to_field:
turns: model_input
apply_to_streams:
- questions
- type: Rename
field_to_field:
model: model_id
user_prompt: judge_input
judgment: judge_output
apply_to_streams:
- judgment
- type: Copy
field: judge/0
to_field: judge_model_id
apply_to_streams:
- judgment
- type: Rename
field_to_field:
choices: model_output
apply_to_streams:
- model_answer
- type: Apply
function: str.lower
to_field: model_id
apply_to_streams:
- judgment
- model_answer
_argv:
- model_id
- type: MapInstanceValues
mappers:
model_id:
vicuna-13b-hao-0515: vicuna-13b-v1.3
vicuna-30b-gpt4: vicuna-33b-v1.3
strict: False
apply_to_streams:
- judgment
- model_answer
- type: Copy
field: model_output/0/turns
to_field: model_output
apply_to_streams:
- model_answer
- type: JoinStreams
left_stream: questions
right_stream: judgment
how: inner
on:
- question_id
new_stream_name: merged_stream
- type: JoinStreams
left_stream: merged_stream
right_stream: model_answer
how: inner
on:
- question_id
- model_id
new_stream_name: merged_stream
- type: DeleteSplits
splits:
- questions
- model_answer
- judgment
- type: RenameSplits
mapper:
merged_stream: test
- type: SelectFields
fields:
- question_id
- category
- model_input
- reference
- turn
- model_id
- judge_model_id
- score
- model_output
- judge_input
- judge_output
[source]Explanation about SequentialOperatorยถ
A class representing a sequential operator in the streaming system.
A sequential operator is a type of MultiStreamOperator that applies a sequence of other operators to a MultiStream. It maintains a list of StreamingOperator`s and applies them in order to the `MultiStream.
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.
- Attributes:
- 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.
- 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}.
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โ. Note that mapped values are defined by their string representation, so mapped values must be converted to strings.
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 any additional arguments are field names whose values will be passed directly to the function specified
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 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 SelectFieldsยถ
Keep only specified fields from each instance in a stream.
- Args:
fields (List[str]): The fields to keep from each instance.
Explanation about DeleteSplitsยถ
Operator which delete splits in stream.
- Attributes:
splits (List[str]): The splits to delete from the stream.
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}}]
Read more about catalog usage here.