sc1 = DataModule.loadhf('jondurbin/truthy-dpo-v0.1') sc2 =…
- User
sc1 = DataModule.load_hf('jondurbin/truthy-dpo-v0.1') sc2 = DataModule.load_hf('Doctor-Shotgun/theory-of-mind-dpo') sc3 = DataModule.load_hf('abacusai/ARC_DPO_FewShot') sc4 = DataModule.load_hf('Yannael/orca_DPO_pairs') sc5 = DataModule.load_hf('argilla/distilabel-math-preference-dpo') sc6 = DataModule.load_hf('argilla/ultrafeedback-binarized-preferences') sc7 = DataModule.load_hf('mlabonne/chatml-OpenHermes2.5-dpo-binarized-alpha')
def apply_template1(row): chosen = "### Question: " + row['prompt'] + '\n### Answer: ' + row['chosen'] rejected = ["### Question: " + row['prompt'] + '\n### Answer: ' + r for r in row['rejected']]
codereturn {'chosen': chosen, 'rejected': rejected}sc1 = sc1.map(apply_template1)
def apply_template2(row): chosen = "### Question: " + row['prompt'] + '\n### Answer: ' + row['chosen'] rejected = ["### Question: " + row['prompt'] + '\n### Answer: ' + r for r in row['rejected']]
codereturn {'chosen': chosen, 'rejected': rejected}sc2 = sc2.map(apply_template2)
def apply_template3(row): chosen = "### Question: " + row['prompt'] + '\n### Answer: ' + row['chosen'] rejected = ["### Question: " + row['prompt'] + '\n### Answer: ' + r for r in row['rejected']]
codereturn {'chosen': chosen, 'rejected': rejected}sc3 = sc3.map(apply_template3)
def apply_template4(row): chosen = "### Question: " + row['question'] + '\n### Answer: ' + row['chosen'] rejected = ["### Question: " + row['question'] + '\n### Answer: ' + r for r in row['rejected']]
codereturn {'chosen': chosen, 'rejected': rejected}sc4 = sc4.map(apply_template4)
def apply_template5(row): chosen = "### Question: " + row['instruction'] + '\n### Answer: ' + row['chosen_response'] rejected = ["### Question: " + row['instruction'] + '\n### Answer: ' + r for r in row['rejected_response']]
codereturn {'chosen': chosen, 'rejected': rejected}sc5 = sc5.map(apply_template5)
def apply_template6(row): chosen = "### Question: " + row['instruction'] + '\n### Answer: ' + row['chosen_response'] rejected = ["### Question: " + row['instruction'] + '\n### Answer: ' + r for r in row['rejected_response']]
codereturn {'chosen': chosen, 'rejected': rejected}sc6 = sc6.map(apply_template6)
def apply_template7(row): chosen = "### Question: " + row['question'] + '\n### Answer: ' + row['chosen'] rejected = ["### Question: " + row['question'] + '\n### Answer: ' + r for r in row['rejected']]
- Assistant
To concatenate datasets like
sc1,sc2, and so on, which you have loaded and processed from Hugging Face's Hub (hf), you should first ensure that all the datasets are in a compatible format for concatenation. Based on your processing, it seems you have standardized the output format to have achosenandrejectedstructure, which is good.If you are using the 🤗 Datasets library, you can make use of the
concatenate_datasetsfunction from thedatasetspackage. However, care should be taken to ensure that all datasets have the same schema (columns). - User
ValueError: Expected a list of Dataset objects or a list of IterableDataset objects, but element at position 0 is a DataModule.
- Assistant
- User
- Assistant
Given your
DataModuleclass and its capabilities, concatenating or merging the datasets is accomplished through a class method designed for this purpose. The method , as defined in the class, is intended to concatenate datasets across multiple instances of . It checks that none of the datasets are being streamed (since streamed datasets cannot be simply concatenated due to their nature of being fetched dynamically) and then proceeds to concatenate the datasets for the , , and splits where available.