πŸ“„ MtragΒΆ

MTRAG: a comprehensive and diverse human-generated multi-turn RAG dataset, accompanied by four document corpora. To the best of our knowledge, MTRAG is the first end-to-end human-generated multi-turn RAG benchmark that reflects real-world properties of multi-turn conversations.

Tags: license:apache-2.0, category:dataset

cards.rag.mtrag

type: TaskCard
loader: 
  type: LoadCSV
  files: 
    test: https://raw.githubusercontent.com/IBM/mt-rag-benchmark/refs/heads/main/human/generation_tasks/reference+RAG.jsonl
  file_type: json
  lines: True
  data_classification_policy: 
    - public
preprocess_steps: 
  - type: MapInstanceValues
    mappers: 
      Answerability: 
        ['UNANSWERABLE']: False
        ['ANSWERABLE']: True
        ['PARTIAL']: True
  - type: Copy
    field_to_field: 
      targets/*/text: reference_answers
      Answerability: is_answerable_label
      task_id: question_id
      contexts/*/document_id: reference_context_ids
      contexts/*/text: reference_contexts
      input/*/speaker: roles
      input/*/text: contents
  - type: ZipFieldValues
    fields: 
      - roles
      - contents
    to_field: conversation
  - type: Dictify
    field: conversation
    with_keys: 
      - role
      - content
    to_field: question
    process_every_value: True
task: tasks.rag.end_to_end
templates: 
  default: templates.rag.end_to_end.json_predictions
[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 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 ZipFieldValuesΒΆ

Zips values of multiple fields in a given instance, similar to list(zip(*fields)).

The value in each of the specified β€˜fields’ is assumed to be a list. The lists from all β€˜fields’ are zipped, and stored into β€˜to_field’.

If β€˜longest’=False, the length of the zipped result is determined by the shortest input value.
If β€˜longest’=True, the length of the zipped result is determined by the longest input, padding shorter inputs with None-s.

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.

Example:

Loading csv

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

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".

References: templates.rag.end_to_end.json_predictions, tasks.rag.end_to_end

Read more about catalog usage here.