π GovtΒΆ
cards.rag.mtrag.documents.govt
TaskCard(
loader=LoadJsonFile(
files={
"test": "https://github.com/IBM/mt-rag-benchmark/raw/refs/heads/main/corpora/document_level/govt.jsonl.zip",
},
compression="zip",
lines=True,
data_classification_policy=[
"public",
],
),
preprocess_steps=[
Cast(
field="title",
to="str",
),
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 LoadJsonFile
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 LoadJsonFileΒΆ
Loads data from JSON 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. lines: Bool indicate if it is json lines file structure. Otherwise, assumes a single json object in the file. data_field: optional field within the json object, that contains the list of instances.
- Example:
Loading json lines
load_csv = LoadJsonFile(files={'train': 'path/to/train.jsonl'}, line=True, 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.