πŸ“„ CloudΒΆ

cards.rag.mtrag.documents.cloud

TaskCard(
    loader=LoadCSV(
        files={
            "test": "https://github.com/IBM/mt-rag-benchmark/raw/refs/heads/main/corpora/cloud.jsonl.zip",
        },
        compression="zip",
        file_type="json",
        lines=True,
        data_classification_policy=[
            "public",
        ],
    ),
    preprocess_steps=[
        Set(
            fields={
                "title": "",
            },
        ),
        Wrap(
            field="text",
            inside="list",
            to_field="passages",
        ),
    ],
    task="tasks.rag.corpora",
    templates={
        "empty": InputOutputTemplate(
            input_format="",
            output_format="",
        ),
    },
)
[source]

from unitxt.collections_operators import Wrap
from unitxt.loaders import LoadCSV
from unitxt.operators import Set
from unitxt.templates import InputOutputTemplate

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 SetΒΆ

Sets specified fields in each instance, in a given stream or all streams (default), with specified values. If fields exist, updates them, if do not exist – adds 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:

# Set a value of a list consisting of β€œpositive” and β€œnegative” do field β€œclasses” to each and every instance of all streams Set(fields={"classes": ["positive","negatives"]})

# In each and every instance of all streams, field β€œspan” is to become a dictionary containing a field β€œstart”, in which the value 0 is to be set Set(fields={"span/start": 0}

# In all instances of stream β€œtrain” only, Set field β€œclasses” to have the value of a list consisting of β€œpositive” and β€œnegative” Set(fields={"classes": ["positive","negatives"], apply_to_stream=["train"]})

# Set field β€œclasses” to have the value of a given list, preventing 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 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 InputOutputTemplateΒΆ

Generate field β€˜source’ from fields designated as input, and fields β€˜target’ and β€˜references’ from fields designated as output, of the processed instance.

Args specify the formatting strings with which to glue together the input and reference fields of the processed instance into one string (β€˜source’ and β€˜target’), and into a list of strings (β€˜references’).

References: tasks.rag.corpora

Read more about catalog usage here.