π EnΒΆ
HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answering. HotpotQA is a new dataset with 113k Wikipedia-based question-answer pairs with four key features: (1) the questions require finding and reasoning over multiple supporting documents to answer; (2) the questions are diverse and not constrained to any pre-existing knowledge bases or knowledge schemas; (3) we provide sentence-level supporting facts required for reasoning, allowingQA systems to reason with strong supervision and explain the predictions; (4) we offer a new type of factoid comparison questions to test QA systems ability to extract relevant facts and perform necessary comparison.
Tags: license:CC BY-SA 4.0, url:https://huggingface.co/datasets/BeIR/hotpotqa, category:dataset
cards.rag.documents.hotpotqa.en
TaskCard(
loader=LoadHF(
path="hotpotqa/hotpot_qa",
revision="refs/convert/parquet",
splits=[
"train",
"test",
"validation",
],
data_classification_policy=[
"public",
],
),
preprocess_steps=[
Join(
field="context/sentences",
by=" ",
to_field="context_sentences",
process_every_value=True,
),
ZipFieldValues(
fields=[
"context/title",
"context_sentences",
],
to_field="documents",
),
Explode(
field="documents",
to_field="document",
),
Copy(
field="document/0",
to_field="document_id",
),
Copy(
field="document/0",
to_field="title",
),
Replace(
field="document/1",
old="Β ",
new=" ",
),
Wrap(
field="document/1",
inside="list",
to_field="passages",
),
Deduplicate(
by=[
"document_id",
],
),
],
task="tasks.rag.corpora",
templates={
"empty": InputOutputTemplate(
input_format="",
output_format="",
),
},
)
[source]from unitxt.collections_operators import Explode, Wrap
from unitxt.loaders import LoadHF
from unitxt.operators import Copy, Deduplicate, ZipFieldValues
from unitxt.string_operators import Join, Replace
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 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 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 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 byCopy(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 DeduplicateΒΆ
Deduplicate the stream based on the given fields.
- Args:
by (List[str]): A list of field names to deduplicate by. The combination of these fieldsβ values will be used to determine uniqueness.
- Examples:
>>> dedup = Deduplicate(by=["field1", "field2"])
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.