Datasets:

Sub-tasks:
extractive-qa
Languages:
English
Multilinguality:
monolingual
Size Categories:
1M<n<10M
Language Creators:
found
Annotations Creators:
no-annotation
Source Datasets:
original
ArXiv:
License:
lotte_passages / lotte_passages.py
colbertv2's picture
Update lotte_passages.py
9691ca2
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO: Address all TODOs and remove all explanatory comments
"""TODO: Add a description here."""
import csv
import json
import os
import datasets
import pandas as pd
import zipfile
import ast
# TODO: Add BibTeX citation
# Find for instance the citation on arxiv or on the dataset repo/website
_CITATION = """\
@inproceedings{santhanam-etal-2022-colbertv2,
title = "{C}ol{BERT}v2: Effective and Efficient Retrieval via Lightweight Late Interaction",
author = "Santhanam, Keshav and
Khattab, Omar and
Saad-Falcon, Jon and
Potts, Christopher and
Zaharia, Matei",
booktitle = "Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
month = jul,
year = "2022",
address = "Seattle, United States",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2022.naacl-main.272",
pages = "3715--3734",
abstract = "Neural information retrieval (IR) has greatly advanced search and other knowledge-intensive language tasks. While many neural IR methods encode queries and documents into single-vector representations, late interaction models produce multi-vector representations at the granularity of each token and decompose relevance modeling into scalable token-level computations. This decomposition has been shown to make late interaction more effective, but it inflates the space footprint of these models by an order of magnitude. In this work, we introduce Maize, a retriever that couples an aggressive residual compression mechanism with a denoised supervision strategy to simultaneously improve the quality and space footprint of late interaction. We evaluate Maize across a wide range of benchmarks, establishing state-of-the-art quality within and outside the training domain while reducing the space footprint of late interaction models by 6{--}10x.",
}
"""
# TODO: Add description of the dataset here
# You can copy an official description
_DESCRIPTION = """\
LoTTE Passages Dataset for ColBERTv2
"""
# TODO: Add a link to an official homepage for the dataset here
_HOMEPAGE = "https://huggingface.co/datasets/colbertv2/lotte"
# TODO: Add the licence for the dataset here if you can find it
_LICENSE = ""
_URL = {
"pooled": "https://huggingface.co/datasets/colbertv2/lotte_passages/resolve/main/pooled/",
"lifestyle": "https://huggingface.co/datasets/colbertv2/lotte_passages/resolve/main/lifestyle/",
"recreation": "https://huggingface.co/datasets/colbertv2/lotte_passages/resolve/main/recreation/",
"science": "https://huggingface.co/datasets/colbertv2/lotte_passages/resolve/main/science/",
"technology": "https://huggingface.co/datasets/colbertv2/lotte_passages/resolve/main/technology/",
"writing": "https://huggingface.co/datasets/colbertv2/lotte_passages/resolve/main/writing/"
}
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
class NewDataset(datasets.GeneratorBasedBuilder):
"""TODO: Short description of my dataset."""
VERSION = datasets.Version("1.1.0")
# This is an example of a dataset with multiple configurations.
# If you don't want/need to define several sub-sets in your dataset,
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
# If you need to make complex sub-parts in the datasets with configurable options
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
# BUILDER_CONFIG_CLASS = MyBuilderConfig
# You will be able to load one or the other configurations in the following list with
# data = datasets.load_dataset('my_dataset', 'first_domain')
# data = datasets.load_dataset('my_dataset', 'second_domain')
BUILDER_CONFIGS = [
datasets.BuilderConfig(name="pooled", version=VERSION, description=""),
datasets.BuilderConfig(name="lifestyle", version=VERSION, description=""),
datasets.BuilderConfig(name="recreation", version=VERSION, description=""),
datasets.BuilderConfig(name="science", version=VERSION, description=""),
datasets.BuilderConfig(name="technology", version=VERSION, description=""),
datasets.BuilderConfig(name="writing", version=VERSION, description=""),
#datasets.BuilderConfig(name="pooled_search_valid", version=VERSION, description=""),
#datasets.BuilderConfig(name="pooled_search_test", version=VERSION, description=""),
#datasets.BuilderConfig(name="pooled_forum_valid", version=VERSION, description=""),
#datasets.BuilderConfig(name="pooled_forum_test", version=VERSION, description=""),
#datasets.BuilderConfig(name="lifestyle_search", version=VERSION, description=""),
#datasets.BuilderConfig(name="lifestyle_forum", version=VERSION, description=""),
#datasets.BuilderConfig(name="recreation_search", version=VERSION, description=""),
#datasets.BuilderConfig(name="recreation_forum", version=VERSION, description=""),
#datasets.BuilderConfig(name="science_search", version=VERSION, description=""),
#datasets.BuilderConfig(name="science_forum", version=VERSION, description=""),
#datasets.BuilderConfig(name="technology_search", version=VERSION, description=""),
#datasets.BuilderConfig(name="technology_forum", version=VERSION, description=""),
#datasets.BuilderConfig(name="writing_search", version=VERSION, description=""),
#datasets.BuilderConfig(name="writing_forum", version=VERSION, description=""),
]
DEFAULT_CONFIG_NAME = "pooled" # It's not mandatory to have a default configuration. Just use one if it make sense.
def _info(self):
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
features = datasets.Features(
{
"doc_id": datasets.Value("int32"),
"author": datasets.Value("string"),
"text": datasets.Value("string")
}
)
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
# This defines the different columns of the dataset and their types
features=features, # Here we define them above because they are different between the two configurations
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
# supervised_keys=("sentence", "label"),
# Homepage of the dataset for documentation
homepage=_HOMEPAGE,
# License for the dataset if available
license=_LICENSE,
# Citation for the dataset
citation=_CITATION,
)
def _split_generators(self, dl_manager):
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
_URLS = {
"dev_collection": _URL[self.config.name] + "dev_collection.jsonl",
"test_collection": _URL[self.config.name] + "test_collection.jsonl",
}
downloaded_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(name="dev_collection", gen_kwargs={"filepath": downloaded_files["dev_collection"]}),
datasets.SplitGenerator(name="test_collection", gen_kwargs={"filepath": downloaded_files["test_collection"]}),
]
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
def _generate_examples(self, filepath):
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
first_row = True
with open(filepath, 'r', encoding="utf-8") as f:
for key, row in enumerate(f):
#for row in rows:
data = json.loads(row)
if len(data) == 3:
current_query = data#[i]
if "author" in current_query.keys():
author = current_query['author']
else:
author = ""
yield current_query["doc_id"], {
"doc_id": current_query["doc_id"],
"author": author,
"text": current_query["text"]
}
else:
for i in range(0, len(data)):
assert len(data) == 268880 or len(data) == 119458 or len(data) == 2428763 or len(data) == 2818926 #lifestyle and pooled bug
if len(data) == 268880 or len(data) == 119458 or len(data) == 2428763 or len(data) == 2818926:
if len(data) == 268880:
current_query = {"doc_id": 0, "author": "Julie Baumler", "text": "In my experience rabbits are very easy to housebreak. They like to pee and poop in the same place every time, so in most cases all you have to do is put a little bit of their waste in the litter box and they will happily use the litter box. It is very important that if they go somewhere else, miss the edge or kick waste out of the box that you clean it up well and immediately as otherwise those spots will become existing places to pee and poop. When you clean the box, save a little bit of waste and put it in the cleaned box so it smells right to them. For a more foolproof method, you can get a piece of wood soaked with their urine and put that in the box along with droppings or cage them so that they are only in their litter box for a week. Generally, if I try the first method and find that they are not using only the box on the first day, I go for the litter box only for a week method. The wood block works well if you are moving from a hutch outdoors to a litter box indoors. If you have an indoor cage, you can use the cage itself as the litter box (or attach a litter box to the section of the cage the rabbit has used for waste.) Be sure to use clay or newsprint litter as the other types aren't necessarily good for rabbits. Wood litter is okay if you are sure it isn't fir. The most important thing is to clean anywhere they have an accident. High sided boxes help with avoiding kicking soiled litter out of the box, which is the biggest cause of failure in my experience."}
elif len(data) == 119458:
current_query = {"doc_id": 0, "author": "forefinger", "text": "Normal double-acting baking powder makes CO2 (thus giving a rising effect) in two ways: when it gets wet, and when it is heated. Baking soda only makes CO2 when it gets wet. From Wikipedia: The acid in a baking powder can be either fast-acting or slow-acting.[6] A fast-acting acid reacts in a wet mixture with baking soda at room temperature, and a slow-acting acid will not react until heated in an oven. Baking powders that contain both fast- and slow-acting acids are double acting; those that contain only one acid are single acting. By providing a second rise in the oven, double-acting baking powders increase the reliability of baked goods by rendering the time elapsed between mixing and baking less critical, and this is the type most widely available to consumers today."}
elif len(data) == 2428763:
current_query = {"doc_id": 0, "author": "", "text": "A native speaker would interpret them as having the same meaning. You could say \"I'm ill,\" or you could say \"I'm sick\". \"I'm ill\" could be classed as more formal language."}
elif len(data) == 2818926:
current_query = {"doc_id": 0, "author": "", "text": "It's the fifth element after earth, air, fire, and water, so it is presumably superior to those or completing those."}
###########################################################################
#assert False
# if i + 1 == 119593: # Error rows for lifestyle
# #assert False
# print("Resolving error rows for lifestyle")
# error_rows = [{"doc_id": 119593, "author": "wabisabied", "text": "Can anybody point out what my problem with my guitar might be? Yes, it might be that the lighter gauge strings are sitting too deep in the nut slots. If the guitar was set up for heavier gauge strings, the slots will be wider than optimal for the new, lighter set, thus the strings will sit deeper and be too close to the frets. This can cause the buzzing, incorrect pitch and dead notes you are encountering. Reverting to heavier gauge strings might get you back on track, but you\u2019ll likely have to readjust saddles and truss rod, as well. In addition to the nut slot depth, the lower tension of lighter gauge strings will also reduce the relief, the slight concave bend, of the neck. This can also cause buzzing, incorrect pitch and dead notes. Since you tried adjusting relief with the truss rod to no better effect, I suspect the nut is a bigger impediment to a proper set up than the relief. Best solution at this point is to take it to a guitar tech, maybe the shop you bought from, and have it set up for the string gauges you prefer. As for the neck shifting and settling into bad alignment, it\u2019s hard to make any judgements without seeing it. If it truly is misaligned, then that is a structural problem and may warrant replacement under warranty. However a lot of new guitar players have problems with pushing the e string off the fret board, so it could just be part of the learning curve for you. Bottom line, I\u2019d take it to a tech and get it sorted out by an expert. However if you\u2019re still inclined to work it out yourself, Fender provides guidance for set ups here: How do I set up my Stratocaster guitar properly?"},
# {"doc_id": 119594, "author": "Edward", "text": "Those look like chord symbols for the backing track. The book probably says this the first time that notation is used."},
# {"doc_id": 119595, "author": "musicamante", "text": "Instead of focusing on the second bar, take a look at the first one. While the first note is a D, as the chord is, the second is clearly not an A, but its a C#. When you have [capitalized] letters on top of your staff, they most probably indicate the tonic (or the root) of the chord that is going to be played, not the specific note, otherwise the note to be played by the bass will be what is followed by the slash (if it exists), unless explicitly written in the instrument notation. In your case the bass line is written, but if its not and you see something like A/C# it means that the bass should theoretically play the C# note, even when the actual chord is A [major]: a more correct chord writing of the above would have A/C# written in the second half of the first measure. In this specific case, the text-written note does not indicate the root note of the chord (so it should be [A]), but the basic chord itself: C# is the third of A [major]. Do consider that it is possible that a note of the bass line can be a note that is not part of the overlying harmony: you can have a natural C in the bass, even if the harmony requires a C# (and even a B\u266d, which is not always the same thing)."},
# {"doc_id": 119596, "author": "Aaron", "text": "According to the charts at https://norlanbewley.com/bewleymusic/trombone-slide-position-chart/ and https://olemiss.edu/lowbrass/studio/fingeringcharts/tenorandbasstromboneposition.pdf... note Norlan Bewliey position(s) Ole Miss position(s) C 1, 3, 5 1, 3 C#/Db 2, 4, 5 2, 5 D 1, 3, 4 1, short 3, 4 D#/Eb 3, 2 short 2, 3 E 2 2 F 1 1 F#/Gb 3 short 3 G 2 short 2 G#/Ab 3 3 A 2 2 A#/Bb 1 1, 3 B 2 C 1, 3 C#/Db 2 D 1, short 3 D#/Eb short 2, 3 E 2 F 1"},
# {"doc_id": 119597, "author": "musicamante", "text": "This question could have tons of answers, but most of them would be based on psychoacustics (even if they are not aware about that). Its mostly about size and perception. Think about listening to two sounds. What would you listen better (or, what you could better differentiate)? listening to both sounds coming from the same source listening to those sounds coming from different positions The simple answer is clearly the second, but that depends on a sum of factors. Different sounds (most importantly, similar sounds, including two voices, no matter how different they could be) often have common frequencies that often create ghost notes in our heads (look up for Auditory illusions). Having [at least] two different sounds coming from two distinct sources (our two ears), makes us easier to make a better distinction between them and allows us to better create the correlation between those sounds. Its not that different from what the binocular vision allows us (I know, its not the same, but its just for the example): imagine seeing an apple on the proverbial table. When you see the same image from your left eye and from your right eye, youd have no depth perception. Yes, its almost the same image, but thats just it, a perception of an apple on a table. Having different (and, obviously, correlatable) images from both eyes gives you a hugely different perception of what youre seeing. You can see the size of the apple, related to that of the table; you can picture the size of the apple; if you were to touch the apple, you would certainly be able to on the first attempt. The same happens in the panning of similar (but differently-voiced) vocals. It gives them space. And a three-dimensional object is usually much more interesting than a bidimensional one. Having two similar sounds (as in doubled vocals, which share lots of common frequencies), creates more space, and makes it much more interesting. It is not the same as having a guitar on the left and a drum on the right, as theres much less correlation between them. Having doubled vocals on different positions makes them bigger, which, on our minds, also makes them more important."}]
# for row in error_rows:
# yield row['doc_id'], {
# "doc_id": row['doc_id'],
# "author": row['author'],
# "text": row['text']
# }
###########################################################################
if first_row:
if "author" in current_query.keys():
author = current_query['author']
else:
author = ""
yield i, {
"doc_id": current_query["doc_id"],
"author": author,
"text": current_query["text"]
}
first_row = False
current_query = data[i]
if "author" in current_query.keys():
author = current_query['author']
else:
author = ""
yield i + 1, {
"doc_id": current_query["doc_id"] + 1,
"author": author,
"text": current_query["text"]
}