in lm_human_preferences/datasets/cnndm.py [0:0]
def cnndm_generator(mode, seed=0, shuffle=False, comm=None):
# data originally from https://github.com/abisee/cnn-dailymail
if mode == 'valid':
mode = 'val'
with open(gcs.download_file_cached(f'https://openaipublic.blob.core.windows.net/lm-human-preferences/datasets/cnndm/url_lists/all_{mode}.txt', comm=comm)) as f:
urls = [line.strip() for line in f]
if shuffle:
random.seed(seed)
random.shuffle(urls)
# if n_eval > 0:
# urls = urls[:n_eval]
urls_dir = gcs.download_directory_cached(f'gs://lm-human-preferences/datasets/cnndm/cache_{mode}', comm=comm)
for i, url in enumerate(urls):
path = os.path.join(urls_dir, get_path_of_url(url))
text = open(path).read()
text = clean_up_start(text)
text = ftfy.fix_text(text)
text = re.sub(r"\n{3,}", "\n\n", text)
text = text.split('@highlight')[0].strip()
yield text