rename to train.jsonl.gz
Browse files
personalized_passkey_retrieval.py
DELETED
|
@@ -1,91 +0,0 @@
|
|
| 1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 2 |
-
#
|
| 3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
-
# you may not use this file except in compliance with the License.
|
| 5 |
-
# You may obtain a copy of the License at
|
| 6 |
-
#
|
| 7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
-
#
|
| 9 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
-
# See the License for the specific language governing permissions and
|
| 13 |
-
# limitations under the License.
|
| 14 |
-
"""personalized_passkey_retrieval: a synthetic dataset to evaluate long-context embeddings"""
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
import json
|
| 18 |
-
import gzip
|
| 19 |
-
import datasets
|
| 20 |
-
|
| 21 |
-
logger = datasets.logging.get_logger(__name__)
|
| 22 |
-
|
| 23 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
| 24 |
-
_CITATION = """\
|
| 25 |
-
@inproceedings{Wang2023ImprovingTE,
|
| 26 |
-
title={Improving Text Embeddings with Large Language Models},
|
| 27 |
-
author={Liang Wang and Nan Yang and Xiaolong Huang and Linjun Yang and Rangan Majumder and Furu Wei},
|
| 28 |
-
year={2023},
|
| 29 |
-
}
|
| 30 |
-
"""
|
| 31 |
-
|
| 32 |
-
# You can copy an official description
|
| 33 |
-
_DESCRIPTION = """\
|
| 34 |
-
This dataset contains synthetic data for personalized passkey retrieval.
|
| 35 |
-
It is only intended for evaluation purposes, you should not use it for training.
|
| 36 |
-
"""
|
| 37 |
-
|
| 38 |
-
_URLS = {
|
| 39 |
-
"train": "personalized_passkey_retrieval.jsonl.gz"
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
class Query2docMsmarco(datasets.GeneratorBasedBuilder):
|
| 44 |
-
VERSION = datasets.Version("0.1.0")
|
| 45 |
-
BUILDER_CONFIGS = [
|
| 46 |
-
datasets.BuilderConfig(name='plain_text', version=VERSION, description='plain text')
|
| 47 |
-
]
|
| 48 |
-
|
| 49 |
-
def _info(self):
|
| 50 |
-
features = datasets.Features(
|
| 51 |
-
{
|
| 52 |
-
"query": datasets.Value("string"),
|
| 53 |
-
"candidates": datasets.features.Sequence(datasets.Value("string")),
|
| 54 |
-
"label": datasets.Value("int32"),
|
| 55 |
-
"context_length": datasets.Value("int32"),
|
| 56 |
-
}
|
| 57 |
-
)
|
| 58 |
-
return datasets.DatasetInfo(
|
| 59 |
-
description=_DESCRIPTION,
|
| 60 |
-
features=features,
|
| 61 |
-
citation=_CITATION,
|
| 62 |
-
)
|
| 63 |
-
|
| 64 |
-
def _split_generators(self, dl_manager):
|
| 65 |
-
downloaded_files = dl_manager.download(_URLS)
|
| 66 |
-
print(downloaded_files)
|
| 67 |
-
return [
|
| 68 |
-
datasets.SplitGenerator(
|
| 69 |
-
name=datasets.Split.TRAIN,
|
| 70 |
-
# These kwargs will be passed to _generate_examples
|
| 71 |
-
gen_kwargs={
|
| 72 |
-
"filepath": downloaded_files["train"],
|
| 73 |
-
"split": "train",
|
| 74 |
-
},
|
| 75 |
-
),
|
| 76 |
-
]
|
| 77 |
-
|
| 78 |
-
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 79 |
-
def _generate_examples(self, filepath, split):
|
| 80 |
-
id_ = 0
|
| 81 |
-
with gzip.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
|
| 82 |
-
for line in f:
|
| 83 |
-
if line:
|
| 84 |
-
example = json.loads(line)
|
| 85 |
-
yield id_, {
|
| 86 |
-
"query": example["query"],
|
| 87 |
-
"candidates": example["candidates"],
|
| 88 |
-
"label": example["label"],
|
| 89 |
-
"context_length": example["context_length"],
|
| 90 |
-
}
|
| 91 |
-
id_ += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
personalized_passkey_retrieval.jsonl.gz → train.jsonl.gz
RENAMED
|
File without changes
|