کدمو درست کن: from unsloth.chattemplates import getchattemplate tokenizer =…
- User
کدمو درست کن: from unsloth.chat_templates import get_chat_template
tokenizer = get_chat_template( tokenizer, chat_template = "phi-3", # Supports zephyr, chatml, mistral, llama, alpaca, vicuna, vicuna_old, unsloth mapping = {"role" : "from", "content" : "value", "user" : "human", "assistant" : "gpt"}, # ShareGPT style )
def formatting_prompts_func(examples): convos = [ [ {"role":"user", "content":query}, {"role":"assistant", "content":content} ] for query, content in zip(examples["answer"], examples["context"]) ] texts = [tokenizer.apply_chat_template(convo, tokenize = False, add_generation_prompt = False) for convo in convos] return { "text" : texts, } pass
from datasets import load_dataset dataset = load_dataset("xmanii/Persian-Math-SFT", split = "train") dataset = dataset.map(formatting_prompts_func, batched = True,)
- Assistant
به نظر میرسد کد شما به درستی عمل میکند. اما قبل از اینکه متوجه خطا یا مشکل خاصی بشوید، بهتر است چند نکته مهم را بررسی کنیم.
۱. وارد کردن کتابخانه ها: اطمینان حاصل کنید که تمامی کتابخانههای مورد استفاده (نظیر
unsloth,datasets, و ...) به درستی نصب و وارد شدهاند.۲. ساختار ورودی: به نظر میرسد که در شما از و استفاده میکنید. اطمینان حاصل کنید که این کلیدها در دیتاست شما وجود دارند. ممکن است لازم باشد نام کلیدها را بررسی کنید.