Skip to content

Commit a7daca3

Browse files
authored
switch soda_synthetic_dialogue to HF dataset (LAION-AI#2671)
Fixes LAION-AI#2670 Output ``` For SODA dialogue dataset found 427 faults within the total 1486896 dialogs ```
1 parent 0404a71 commit a7daca3

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

‎model/model_training/custom_datasets/qa_datasets.py‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -275,32 +275,17 @@ def __getitem__(self, index) -> list[str] | tuple[str]:
275275
return (self.pairs[index][0] + " " + self.pairs[index][1],)
276276

277277

278-
class SODADialogue(Dataset):
279-
url = "https://drive.google.com/uc?id=1TOGQfr419n8wpzJpYLLw4nB3tSKD8zXV"
280-
278+
class SODADialogue:
281279
def __init__(self, cache_dir, verbose=True):
282-
path = os.path.join(cache_dir, "soda_dialog.jsonl")
283-
284-
if not os.path.exists(path):
285-
import gzip
286-
import shutil
287-
288-
import gdown
289-
290-
gdown.download(self.url, output=os.path.join(cache_dir, "soda_dialog.jsonl.gz"))
291-
292-
with gzip.open(os.path.join(cache_dir, "soda_dialog.jsonl.gz"), "rb") as f_in:
293-
with open(path, "wb") as f_out:
294-
shutil.copyfileobj(f_in, f_out)
280+
dataset = load_dataset("emozilla/soda_synthetic_dialogue", cache_dir=cache_dir)
295281

296282
self.pairs = []
297283
faulty = 0
298-
with open(path) as fin:
299-
for line in fin:
300-
conversation = json.loads(line)
284+
for split in dataset:
285+
for row in dataset[split]:
301286
question_answer_pairs = ()
302287

303-
question_answers = conversation["text"].split("User: ")
288+
question_answers = row["conversation"].split("User: ")
304289
for question_answer in question_answers[1:]: # first element is empty
305290
try:
306291
question, answer = question_answer.split("\nAssistant: ")

0 commit comments

Comments
 (0)