Read our 2024 Summary blog post!

[[ visible ? '▲ HIDE' : '▼ SHOW BANNER' ]]

|||

Quick search

  • Introduction
  • Installation
  • Loading Datasets
  • Evaluating Datasets
  • Use Cases
  • Guides ✨
  • Examples
  • Blog πŸ“£
  • Code Documentation
  • πŸ“ Catalog
    • πŸ“ Augmentors
    • πŸ“ Benchmarks
    • πŸ“ Cards
      • πŸ“ 20 Newsgroups
      • πŸ“ Cfpb
      • πŸ“ Ai2 Arc
      • πŸ“ Almost Evil
      • πŸ“ Amazon Mass
      • πŸ“ Arena Hard
      • πŸ“ Babi
      • πŸ“ Belebele
      • πŸ“ Boolq
      • πŸ“ Boolq Indic
      • πŸ“ Clinc Oos
      • πŸ“ Coedit
      • πŸ“ Cohere For Ai
      • πŸ“ Coqa
      • πŸ“ Doc Vqa
      • πŸ“ Dynamic Cards For Llm Judges
      • πŸ“ Ffqa Filtered
      • πŸ“ Global Mmlu
      • πŸ“ Global Mmlu Lite Ca
      • πŸ“ Global Mmlu Lite Cs
      • πŸ“ Go Emotions
      • πŸ“ Gpqa
      • πŸ“ Head Qa
      • πŸ“ Legalbench
      • πŸ“ Milu
      • πŸ“ Mlsum
      • πŸ“ Mmlu
      • πŸ“ Mmlu Pro
      • πŸ“ Mmmu
      • πŸ“ Mt
      • πŸ“ Mt Bench
      • πŸ“ Multidoc2Dial
      • πŸ“ Rag
      • πŸ“ Rag Eval
      • πŸ“ Ragbench
      • πŸ“ Reuters21578
      • πŸ“ Reward Bench
      • πŸ“ Safety
      • πŸ“ Text2Sql
      • πŸ“ Universal Ner
      • πŸ“ Winogrande
      • πŸ“ Wmt
      • πŸ“ Wnli
      • πŸ“ Xlsum
      • πŸ“ Xnli
      • πŸ“ Xwinogrande
      • πŸ“„ 20 Newsgroups
      • πŸ“„ 20 Newsgroups Short
      • πŸ“„ Ag News
      • πŸ“„ Ai2D
      • πŸ“„ Almost Evil
      • πŸ“„ Argument Topic
      • πŸ“„ Atis
      • πŸ“„ Atta Q
      • πŸ“„ Attaq
      • πŸ“„ Attaq 500
      • πŸ“„ Banking77
      • πŸ“„ Billsum
      • πŸ“„ Billsum Document Filtered To 10000 Chars
      • πŸ“„ Billsum Document Filtered To 6000 Chars
      • πŸ“„ Bold
      • πŸ“„ Chart Qa
      • πŸ“„ Chart Qa Lmms Eval
      • πŸ“„ Claim Stance Topic
      • πŸ“„ Cnn Dailymail
      • πŸ“„ Coedit Error Detection
      • πŸ“„ Coedit Gec
      • πŸ“„ Cola
      • πŸ“„ Copa
      • πŸ“„ Dart
      • πŸ“„ Dbpedia 14
      • πŸ“„ Ethos Binary
      • πŸ“„ Fin Qa
      • πŸ“„ Financial Tweets
      • πŸ“„ Frames
      • πŸ“„ Hellaswag
      • πŸ“„ Hh Rlhf
      • πŸ“„ Human Eval
      • πŸ“„ Info Vqa
      • πŸ“„ Info Vqa Lmms Eval
      • πŸ“„ Language Identification
      • πŸ“„ Law Stack Exchange
      • πŸ“„ Ledgar
      • πŸ“„ Long Bench V2
      • πŸ“„ Mbpp
      • πŸ“„ Medical Abstracts
      • πŸ“„ Mnli
      • πŸ“„ Mrpc
      • πŸ“„ News Category Classification Headline
      • πŸ“„ Numeric Nlg
      • πŸ“„ Open Australian Legal Qa
      • πŸ“„ Openbook Qa
      • πŸ“„ Piqa
      • πŸ“„ Pop Qa
      • πŸ“„ Pop Qa Robust
      • πŸ“„ Qnli
      • πŸ“„ Qqp
      • πŸ“„ Qtsumm
      • πŸ“„ Quality
      • πŸ“„ Race All
      • πŸ“„ Race High
      • πŸ“„ Race Middle
      • πŸ“„ Rte
      • πŸ“„ Scigen
      • πŸ“„ Sciq
      • πŸ“„ Seed Bench
      • πŸ“„ Simple Qa
      • πŸ“„ Social Iqa
      • πŸ“„ Squad
      • πŸ“„ Sst2
      • πŸ“„ Stsb
      • πŸ“„ Summarize From Human Feedback
      • πŸ“„ Tab Fact
      • πŸ“„ Tablebench
      • πŸ“„ Tablebench Data Analysis
      • πŸ“„ Tablebench Fact Checking
      • πŸ“„ Tablebench Numerical Reasoning
      • πŸ“„ Tablerow Classify
      • πŸ“„ Tldr
      • πŸ“„ Tldr Document Filtered To 10000 Chars
      • πŸ“„ Tldr Document Filtered To 6000 Chars
      • πŸ“„ Toxigen
      • πŸ“„ Trec
      • πŸ“„ Turl Col Type
      • πŸ“„ Unfair Tos
      • πŸ“„ Websrc
      • πŸ“„ Wiki Bio
      • πŸ“„ Wikitq
      • πŸ“„ Wnli
      • πŸ“„ Wsc
      • πŸ“„ Xsum
      • πŸ“„ Yahoo Answers Topics
    • πŸ“ Engines
    • πŸ“ Formats
    • πŸ“ Metrics
    • πŸ“ Operators
    • πŸ“ Processors
    • πŸ“ Recipes
    • πŸ“ Serializers
    • πŸ“ Splitters
    • πŸ“ System Prompts
    • πŸ“ Tasks
    • πŸ“ Templates

πŸ“„ Open Australian Legal QaΒΆ

cards.rag.response_generation.train.open_australian_legal_qa

TaskCard(
    loader=LoadHF(
        path="umarbutler/open-australian-legal-qa",
        name="default",
    ),
    preprocess_steps=[
        SplitRandomMix(
            mix={
                "train": "train[0.5]",
                "validation": "train[0.2]",
                "test": "train[0.3]",
            },
        ),
        Shuffle(),
        Copy(
            field_to_field={
                "source/text": "contexts",
                "answer": "reference_answers",
                "source/citation": "contexts_ids",
            },
        ),
        ListFieldValues(
            fields=[
                "reference_answers",
            ],
            to_field="reference_answers",
        ),
        ListFieldValues(
            fields=[
                "contexts",
            ],
            to_field="contexts",
        ),
        ListFieldValues(
            fields=[
                "contexts_ids",
            ],
            to_field="contexts_ids",
        ),
    ],
    task="tasks.rag.response_generation",
    templates={
        "default": "templates.rag.response_generation.please_respond_chat",
    },
)
[source]

from unitxt.loaders import LoadHF
from unitxt.operators import Copy, ListFieldValues, Shuffle
from unitxt.splitters import SplitRandomMix

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

Loads datasets from the HuggingFace Hub.

It supports loading with or without streaming, and it can filter datasets upon loading.

Args:
path:

The path or identifier of the dataset on the HuggingFace Hub.

name:

An optional dataset name.

data_dir:

Optional directory to store downloaded data.

split:

Optional specification of which split to load.

data_files:

Optional specification of particular data files to load. When you provide a list of data_files to Hugging Face’s load_dataset function without explicitly specifying the split argument, these files are automatically placed into the train split.

revision:

Optional. The revision of the dataset. Often the commit id. Use in case you want to set the dataset version.

streaming (bool):

indicating if streaming should be used.

filtering_lambda (str, optional):

A lambda function for filtering the data after loading.

num_proc (int, optional):

Specifies the number of processes to use for parallel dataset loading.

Example:

Loading glue’s mrpc dataset

load_hf = LoadHF(path='glue', name='mrpc')

Explanation about ShuffleΒΆ

Shuffles the order of instances in each page of a stream.

Args (of superclass):

page_size (int): The size of each page in the stream. Defaults to 1000.

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

Concatenates values of multiple fields into a list, and assigns it to a new field.

Explanation about SplitRandomMixΒΆ

Splits a multistream into new streams (splits), whose names, source input stream, and amount of instances, are specified by arg β€˜mix’.

The keys of arg β€˜mix’, are the names of the new streams, the values are of the form: β€˜name-of-source-stream[percentage-of-source-stream]’ Each input instance, of any input stream, is selected exactly once for inclusion in any of the output streams.

Examples: When processing a multistream made of two streams whose names are β€˜train’ and β€˜test’, by SplitRandomMix(mix = { β€œtrain”: β€œtrain[99%]”, β€œvalidation”: β€œtrain[1%]”, β€œtest”: β€œtest” }) the output is a multistream, whose three streams are named β€˜train’, β€˜validation’, and β€˜test’. Output stream β€˜train’ is made of randomly selected 99% of the instances of input stream β€˜train’, output stream β€˜validation’ is made of the remaining 1% instances of input β€˜train’, and output stream β€˜test’ is made of the whole of input stream β€˜test’.

When processing the above input multistream by SplitRandomMix(mix = { β€œtrain”: β€œtrain[50%]+test[0.1]”, β€œvalidation”: β€œtrain[50%]+test[0.2]”, β€œtest”: β€œtest[0.7]” }) the output is a multistream, whose three streams are named β€˜train’, β€˜validation’, and β€˜test’. Output stream β€˜train’ is made of randomly selected 50% of the instances of input stream β€˜train’ + randomly selected 0.1 (i.e., 10%) of the instances of input stream β€˜test’. Output stream β€˜validation’ is made of the remaining 50% instances of input β€˜train’+ randomly selected 0.2 (i.e., 20%) of the original instances of input β€˜test’, that were not selected for output β€˜train’, and output stream β€˜test’ is made of the remaining instances of input β€˜test’.

References: templates.rag.response_generation.please_respond_chat, tasks.rag.response_generation

Read more about catalog usage here.



<Page contents

>Page contents:

  • πŸ“„ Open Australian Legal Qa
    • Explanation about TaskCard
    • Explanation about LoadHF
    • Explanation about Shuffle
    • Explanation about Copy
    • Explanation about ListFieldValues
    • Explanation about SplitRandomMix
<πŸ“„ Clapnq
πŸ“„ Clapnq>
© Copyright 2023, IBM Research.