Dataset Viewer
Auto-converted to Parquet Duplicate
question
stringlengths
19
109
answer
sequencelengths
1
25
qid
stringlengths
1
5
ctxs
sequencelengths
100
100
total number of death row inmates in the us
[ "2,718" ]
0
[ "\"Presidency of Joseph Estrada\"\npunishable by death penalty. But perhaps the best indicator that this law is not a deterrent to criminality is the ever-increasing number of death convicts. From 1994 to 1995 the number of persons on death row increased from 12 to 104. From 1995 to 1996 it increased to 182. In 199...
big little lies season 2 how many episodes
[ "seven" ]
1
[ "\"The Locket (How I Met Your Mother)\"\nmany \"\"annoying little things, and a few big ones\"\" but one big thing they got absolutely right: That was the Mother. Bill Kuchman of Popculturology said the episode paled in comparison to the previous season's premiere, saying, \"\"You want a legendary \"\"HIMYM\"\" sea...
who sang waiting for a girl like you
[ "Foreigner" ]
2
[ "\"Waiting for a Girl Like You\"\nWaiting for a Girl Like You \"\"Waiting for a Girl Like You\"\" is a 1981 power ballad by the British-American rock band Foreigner. The distinctive synthesizer theme was performed by the then-little-known Thomas Dolby, and this song also marked a major departure from their earlier ...
where do you cross the arctic circle in norway
[ "Saltfjellet" ]
3
["\"Arctic Norway\"\nArctic Norway Arctic Norway () comprises the northernmost parts of Norway that (...TRUNCATED)
who is the main character in green eggs and ham
[ "Sam - I - am" ]
4
["Seussical\ntiny flying \"\"Elephant-Bird\"\", amazing everyone but dismaying Horton, who panics at(...TRUNCATED)
do veins carry blood to the heart or away
[ "to" ]
5
["Vein\nVein Veins are blood vessels that carry blood toward the heart. Most veins carry deoxygenate(...TRUNCATED)
who played charlie bucket in the original charlie and the chocolate factory
[ "Peter Gardner Ostrum" ]
6
["\"Charlie and the Chocolate Factory (franchise)\"\nthe sequel to \"\"Charlie and the Chocolate Fac(...TRUNCATED)
what is 1 radian in terms of pi
[ "1 / 2π" ]
7
["Pi\nand the integral computes the area between that half of a circle and the axis. The trigonometr(...TRUNCATED)
when does season 5 of bates motel come out
[ "February 20 , 2017" ]
8
["\"Bates Motel (season 5)\"\nsubsequently demolished. <onlyinclude></onlyinclude> The season has re(...TRUNCATED)
how many episodes are in series 7 game of thrones
[ "seven" ]
9
["\"Game of Thrones (season 7)\"\nDrama Series. <onlyinclude></onlyinclude> The recurring actors lis(...TRUNCATED)
End of preview. Expand in Data Studio

Dataset Card for "nq_bm25_top100"

More Information needed

generated with

"""
python3.10 -m pip install pyserini==0.25.0
sudo apt install openjdk-11-jdk
cd /dev/shm
mkdir pyserini_cache
cd pyserini_cache
wget https://git.uwaterloo.ca/jimmylin/anserini-indexes/raw/master/index-wikipedia-dpr-20210120-d1b9e6.tar.gz
mkdir indexes
tar xvfz index-wikipedia-dpr-20210120-d1b9e6.tar.gz -C indexes
# rm index-wikipedia-dpr-20210120-d1b9e6.tar.gz
"""

from pyserini.search import LuceneSearcher
import json
import datasets
import numpy as np
import jax.numpy as jnp
import jax
import tqdm
import copy
from EasyLM.sliding_window import sliding_window
from EasyLM.models.neox.neox_model import GPTNeoXConfig


def decode_doc(doc):
    return json.loads(doc.raw())["contents"]


def search_question(batch, searcher):
    qids = batch["qid"]
    hits = searcher.batch_search(batch["question"],qids,threads=300,k=100)
    ctxs_per_doc = [[hit.docid for hit in hits[qid]] for qid in qids]
    ctxs = sum(ctxs_per_doc,[])
    doc_res = searcher.batch_doc(ctxs,threads=300)
    docs_raw = [[decode_doc(doc_res[x]) for x in doc_hits] for doc_hits in ctxs_per_doc]
    batch["ctxs"] = docs_raw
    return batch

WIKI_INDEX_PATH = "/dev/shm/pyserini_cache/indexes/index-wikipedia-dpr-20210120-d1b9e6/"
def gen(split):
    nq = datasets.load_dataset("iohadrubin/nq_closedbook", cache_dir="/dev/shm/datasets")
    dataset = nq[split]
    qid = list(map(str,range(len(dataset))))
    dataset = dataset.add_column("qid",qid)
    return dataset
def example_generator(split):
    dataset = gen(split)
    searcher = LuceneSearcher(WIKI_INDEX_PATH)
    itr_dataset = dataset.to_iterable_dataset()
    mapped_itr_dataset = itr_dataset.map(search_question,
                        batch_size=50,
                        batched=True,
                        fn_kwargs={"searcher":searcher},
                        
                        )
    yield from iter(mapped_itr_dataset)
    
import fire
import os

# python3.10 -m EasyLM.nq_data generate_nq
def generate_nq():
    searcher = LuceneSearcher(WIKI_INDEX_PATH)
    dataset_dict = {}
    for split in [
                  "train",
                  "validation","test",
                  ]:
        dataset = gen(split)
        dataset_dict[split] = dataset.map(search_question,
                        batch_size=300,
                        batched=True,
                        fn_kwargs={"searcher":searcher},
                        cache_file_name=f"/dev/shm/datasets/nq_bm25_top100_{split}.arrow"
                        
                        )
    
    dataset_dict= datasets.DatasetDict(dataset_dict)
    dataset_dict.push_to_hub("nq_bm25_top100",token=os.environ["HF_TOKEN"])
Downloads last month
7