Git Product home page Git Product logo

Comments (10)

JianxinMa avatar JianxinMa commented on June 12, 2024

是的,function calling与ReAct并非100%对应。具体而言,function calling会丢弃Final Answer前的那一次Thought,这个thought的内容一般是"I now know the final answer."。

至于出现英文回复,原因是:我在将 function calling 转换成 ReAct 时,会自动补一个“Thought: I now know the final answer.”或其中文版本 (见 https://github.com/QwenLM/Qwen/blob/main/openai_api.py#L212 ) —— 原本是应该根据中文请求就补一个中文的Thought的,但是我这里的判断写得疏忽了,导致实际补了个英文的Thought。

等我有空了会去完善下 openai_api.py 里的这部分逻辑。

from qwen-agent.

lucasjinreal avatar lucasjinreal commented on June 12, 2024

@JianxinMa 感谢。加一个thought 他可能能回答中文,但看起来他好像忘记了问题,加一个thought感觉不一定能弥补回来

from qwen-agent.

lucasjinreal avatar lucasjinreal commented on June 12, 2024

@JianxinMa 大佬,

等我有空了会去完善下 openai_api.py 里的这部分逻辑。

这个问题可以优先修复一下吗

from qwen-agent.

JianxinMa avatar JianxinMa commented on June 12, 2024

我尝试了Qwen-14B-Chat,Qwen-7B-Chat没能复现出最终回答“忘记问题”的现象。请问有更多信息以供复现吗?

from qwen-agent.

tuhahaha avatar tuhahaha commented on June 12, 2024

我这边functioncall执行输出是:

Thought: 我需要使用代码解释器API来运行代码
Action: code_interpreter
Action Input:

import datetime

# 计算1974年3月23日是星期几
date = datetime.date(1974, 3, 23)
day_of_week = date.strftime("%A")
day_of_week

Observation: execute_result:

'Saturday'

Thought: I now know the final answer.
Final Answer: 1974年3月23日是星期六。

from qwen-agent.

lucasjinreal avatar lucasjinreal commented on June 12, 2024

@tuhahaha 你可以打印出每一个turn的output吗,你第一个thought不应该是: Thought: 我需要使用code_interpreter来运行代码,计算1974年3月23日是星期几。?

我这边用Qwen14b openaiserver,没有办法得到 最终的结果。

@JianxinMa

是的,function calling与ReAct并非100%对应。具体而言,function calling会丢弃Final Answer前的那一次Thought,这个thought的内容一般是"I now know the final answer."。

至于出现英文回复,原因是:我在将 function calling 转换成 ReAct 时,会自动补一个“Thought: I now know the final answer.”或其中文版本 (见 https://github.com/QwenLM/Qwen/blob/main/openai_api.py#L212 ) —— 原本是应该根据中文请求就补一个中文的Thought的,但是我这里的判断写得疏忽了,导致实际补了个英文的Thought。

等我有空了会去完善下 openai_api.py 里的这部分逻辑。

我还以为大佬理解了我的问题,,,

可以看一下我的debug 输出,貌似对过去openaiserver的数据是没有错的,只是openaiserver再拼接的时候,确实漏掉了一些信息,导致模型输出的总结不到 最终的答案。

from qwen-agent.

tuhahaha avatar tuhahaha commented on June 12, 2024

我这边用14B跑function call的输出是:
------- turn 0 [{"role": "user", "content": " 计算1974年的3月23号是星期几, 必须使用code_interpreter工具"}]
------- turn 0 {"role": "assistant", "content": "Thought: 我需要使用code_interpreter来运行代码,计算1974年3月23日是星期几。", "function_call": {"name": "code_interpreter", "arguments": "py\nimport datetime\n\n# 设置日期\ndate = datetime.datetime(1974, 3, 23)\n\n# 计算星期几\nweekday = date.weekday()\n\n# 星期几的对应字典\nweekday_dict = {\n 0: '星期一',\n 1: '星期二',\n 2: '星期三',\n 3: '星期四',\n 4: '星期五',\n 5: '星期六',\n 6: '星期日'\n}\n\n# 输出结果\nweekday_dict[weekday]\n"}}

------- turn 1 [{"role": "user", "content": " 计算1974年的3月23号是星期几, 必须使用code_interpreter工具"}, {"role": "assistant", "content": "Thought: 我需要使用code_interpreter来运行代码,计算1974年3月23日是星期几。", "function_call": {"name": "code_interpreter", "arguments": "py\nimport datetime\n\n# 设置日期\ndate = datetime.datetime(1974, 3, 23)\n\n# 计算星期几\nweekday = date.weekday()\n\n# 星期几的对应字典\nweekday_dict = {\n 0: '星期一',\n 1: '星期二',\n 2: '星期三',\n 3: '星期四',\n 4: '星期五',\n 5: '星期六',\n 6: '星期日'\n}\n\n# 输出结果\nweekday_dict[weekday]\n"}}, {"role": "function", "name": "code_interpreter", "content": "execute_result:\n\n\n'星期六'\n"}]
------- turn 1 {"role": "assistant", "content": "1974年3月23日是星期六。", "function_call": null}

最终答案也是正常的。
也许你可以看下你是否拉了BrowserQwen和Qwen 最新的代码?

from qwen-agent.

lucasjinreal avatar lucasjinreal commented on June 12, 2024

@tuhahaha 感觉丢给模型的都是差不多的,为啥最后 一个返回的,我的总是英文,而且回答 没有 1974年3月23日是 这一部分?
我用的就是官方最新的代码呢

from qwen-agent.

tuhahaha avatar tuhahaha commented on June 12, 2024

你换一个其他问题也是英文?

from qwen-agent.

lucasjinreal avatar lucasjinreal commented on June 12, 2024

对的,从原理上分析,可能是哪一部分缺失了?

from qwen-agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.