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

【互助】关于Agent中react/ReAct 模板数据如何组织方法 #3750

Closed
txy6666yr opened this issue May 15, 2024 · 8 comments
Closed
Labels
solved This problem has been already solved.

Comments

@txy6666yr
Copy link

txy6666yr commented May 15, 2024

目前的react模板中,一般需要增加role如thought/observation/action等,参考data下readme文件,以及这篇文章。可以直接根据我们目标模型的template组织数据,手动添加到user或者assistant字段中。

如:role包含 user,thought,assistant,微调qwen
qwen的数据组织如下:

<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
{{query}}<|im_end|>
<|im_start|>assistant
{{ans}}<|im_end|>

我们需要增加thought角色:

<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
{{query}}<|im_end|>
<|im_start|>thought
{{thought}}
<|im_end|>
<|im_start|>assistant
{{ans}}<|im_end|>

如只预测assistant只需要把assistant前面的内容都当做user即可
即:

{
        "instruction": "{{query}}<|im_end|>\n<|im_start|>thought\n{{thought}}",
        "input": "",
        "output": "{{ans}}",
        "history": [],
        "system": "You are a helpful assistant."
}

这样即可。
#3667
#3292
#3227

@kapiya
Copy link

kapiya commented May 16, 2024

这样是不是需要修改qwen的template

@kapiya
Copy link

kapiya commented May 16, 2024

类似<|im_end|>的特变标记,是套用template上添加的,如果直接在数据上加上,是不是会有问题

{
        "instruction": "{{query}}<|im_end|>\n<|im_start|>thought\n{{thought}}",
        "input": "",
        "output": "{{ans}}",
        "history": [],
        "system": "You are a helpful assistant."
}

@txy6666yr
Copy link
Author

txy6666yr commented May 16, 2024

类似<|im_end|>的特变标记,是套用template上添加的,如果直接在数据上加上,是不是会有问题

{
        "instruction": "{{query}}<|im_end|>\n<|im_start|>thought\n{{thought}}",
        "input": "",
        "output": "{{ans}}",
        "history": [],
        "system": "You are a helpful assistant."
}

不需要修改template,只是相当于user部分你扩充了,达到了修改template的效果
我的代码不会,你看使用作者框架训练的时候,输出的那个例子是不是符合你要求的就好,作者的这个框架每次训练会输出一个例子的

@kapiya
Copy link

kapiya commented May 16, 2024

类似<|im_end|>的特变标记,是套用template上添加的,如果直接在数据上加上,是不是会有问题

{
        "instruction": "{{query}}<|im_end|>\n<|im_start|>thought\n{{thought}}",
        "input": "",
        "output": "{{ans}}",
        "history": [],
        "system": "You are a helpful assistant."
}

不需要修改template,只是相当于user部分你扩充了,达到了修改template的效果 我的代码不会,你看使用作者框架训练的时候,输出的那个例子是不是符合你要求的就好,作者的这个框架每次训练会输出一个例子的

那就是说我组织数据的时候,就得包含类似的<|im_end|>\n<|im_start|这样的特殊标记了,不知道我理解的对不对

@txy6666yr
Copy link
Author

类似<|im_end|>的特变标记,是套用template上添加的,如果直接在数据上加上,是不是会有问题

{
        "instruction": "{{query}}<|im_end|>\n<|im_start|>thought\n{{thought}}",
        "input": "",
        "output": "{{ans}}",
        "history": [],
        "system": "You are a helpful assistant."
}

不需要修改template,只是相当于user部分你扩充了,达到了修改template的效果 我的代码不会,你看使用作者框架训练的时候,输出的那个例子是不是符合你要求的就好,作者的这个框架每次训练会输出一个例子的

那就是说我组织数据的时候,就得包含类似的<|im_end|>\n<|im_start|这样的特殊标记了,不知道我理解的对不对

是的,我是按照这样训练的,但是我的代码比较旧,不是最新的,你可以试一下,帮大家反馈下~

@kapiya
Copy link

kapiya commented May 16, 2024

3ks,我尝试一下,先把数据重新组织一下

@huchaodong
Copy link

如果react是多轮的怎么组织数据,就是会有多个thought/observation/action等

@kapiya
Copy link

kapiya commented May 17, 2024

如果react是多轮的怎么组织数据,就是会有多个thought/observation/action等

放到history中?

@hiyouga hiyouga added pending This problem is yet to be addressed. solved This problem has been already solved. and removed pending This problem is yet to be addressed. labels May 24, 2024
@hiyouga hiyouga closed this as completed May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved.
Projects
None yet
Development

No branches or pull requests

4 participants