πŸ“„ ClapnqΒΆ

cards.rag.mtrag.documents.clapnq

TaskCard(
    loader=LoadCSV(
        files={
            "test": "https://github.com/IBM/mt-rag-benchmark/raw/refs/heads/main/corpora/clapnq.jsonl.zip",
        },
        compression="zip",
        file_type="json",
        lines=True,
        data_classification_policy=[
            "public",
        ],
    ),
    preprocess_steps=[
        Cast(
            field="_id",
            to="str",
            to_field="document_id",
        ),
        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 Cast
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 CastΒΆ

Casts specified fields to specified types.

Args:

default (object): A dictionary mapping field names to default values for cases of casting failure. process_every_value (bool): If true, all fields involved must contain lists, and each value in the list is then casted. Defaults to False.

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.