Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于prefix数据处理的问题 #49

Open
qibao77 opened this issue Feb 24, 2025 · 2 comments
Open

关于prefix数据处理的问题 #49

qibao77 opened this issue Feb 24, 2025 · 2 comments

Comments

@qibao77
Copy link

qibao77 commented Feb 24, 2025

训练数据预处理部分有个make_prefix,给出了<|im_start|>system等前缀,但事实上只要训练数据给定了"prompt": [{
"role": "system",
"content": system,
},{
"role": "user",
"content": question,
}],verl会使用qwen- instruct的apply_chat_template对prompt打包出前缀,不需要手动做这个prefix,不知道是不是我理解的有问题。

@tangsipeng
Copy link

同问,官方的verl代码在 rl_dataset.py 代码中给出了 tokenizer.apply_chat_template 方法,为什么不沿用而改成了 prompt_with_chat_template = chat[0]['content']

@Tim-Siu
Copy link

Tim-Siu commented Feb 25, 2025

作者的实现和TinyZero一样, 可能是为了适配base模型, 直接hardcode了chat_template并修改了rl_dataset.py 不再apply_chat_template.

我为了兼容其他实验在data preprocess的时候额外加入了“apply_chat_template”这个key, 并对rl_dataset.py做了不那么粗暴的修改, 应该能达到类似的效果

row_dict.get("extra_info", {}).get("apply_chat_template", True)

if apply_chat_template:
    prompt_with_chat_template = self.tokenizer.apply_chat_template(chat, add_generation_prompt=True, tokenize=False)
else:
    assert isinstance(chat, str), "If not applying chat_template, the prompt inside the dataentry should be a string"
    prompt_with_chat_template = chat

Tim-Siu/reft-exp@d03393f#diff-58b4f05c6684f8b2fff8cab1fe16fff63c0743d436d02db03dc875f79796756eL140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants