| from datasets import load_dataset | |
| dataset = load_dataset("empgces/torre_de_belem") | |
| def formatting_prompts_func(examples): | |
| convos = examples["conversations"] | |
| texts = [ | |
| tokenizer.apply_chat_template( | |
| convo, | |
| tokenize=False, | |
| add_generation_prompt=False | |
| ).removeprefix("<bos>") | |
| for convo in convos | |
| ] | |
| return {"text": texts} | |
| dataset = dataset.map(formatting_prompts_func, batched=True) | |
| train_dataset = dataset["train"] | |
| eval_dataset = dataset["validation"] | |