torre_de_belem / colab_load_snippet.py
empgces's picture
Upload folder using huggingface_hub
699748e verified
Raw
History Blame Contribute Delete
529 Bytes
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"]