InternLM / MindSearch

🔍 An LLM-based Multi-agent Framework of Web Search Engine (like Perplexity.ai Pro and SearchGPT)
https://mindsearch.netlify.app/
Apache License 2.0
4.54k stars 452 forks source link

mindsearch_agent.py 三个报错 #177

Open XYZliang opened 2 weeks ago

XYZliang commented 2 weeks ago

全新git获取的MindSearch和lagent仓库(之所以不直接安装是因为需要修改lagent部分代码),其余正常pip安装。 修改了terminal.py的15行模型为本地模型internlm2-chat-20b-4bit(使用lmdeploy对internlm2-chat-20b进行量化后的模型) 在运行mindsearch/terminal.py的时候,就出现报错,不影响最后出结果:

[TM][WARNING] [LlamaTritonModel] `max_context_token_num` = 32776.
2024-08-24 21:03:52,268 - lmdeploy - WARNING - get 483 model params
[TM][WARNING] Devicle 0 peer access Device 1 is not available.
[TM][WARNING] Devicle 0 peer access Device 2 is not available.
[WARNING] gemm_config.in is not found; using default GEMM algo
HINT:    Please open http://0.0.0.0:23333 in a browser for detailed api usage!!!
HINT:    Please open http://0.0.0.0:23333 in a browser for detailed api usage!!!
HINT:    Please open http://0.0.0.0:23333 in a browser for detailed api usage!!!
INFO:     Started server process [3134412]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:23333 (Press CTRL+C to quit)
INFO:     127.0.0.1:40196 - "GET /v1/models HTTP/1.1" 200 OK
Launched the api_server in process 3134412, user can kill the server by:
import os,signal
os.kill(3134412, signal.SIGKILL)
INFO:     127.0.0.1:40208 - "POST /v1/completions HTTP/1.1" 200 OK
 <|action_start|> <|interpreter|> 
```python
from web_search_graph import WebSearchGraph

# 初始化 WebSearchGraph 实例
graph = WebSearchGraph()

# 添加根节点
graph.add_root_node("上海今天天气如何?")

# 添加子节点
graph.add_node("上海今天气温是多少?")
graph.add_node("上海今天是否有雨?")

# 添加响应节点
graph.add_response_node()

ERROR:mindsearch.agent.mindsearch_agent:Error executing code: WebSearchGraph.add_node() missing 1 required positional argument: 'node_content' Traceback (most recent call last): File "/data/xyzliang/project/MindSearch/MindSearch/mindsearch/agent/mindsearch_agent.py", line 360, in run_command exec(cmd, globals(), self.local_dict) File "", line 10, in TypeError: WebSearchGraph.add_node() missing 1 required positional argument: 'node_content' Exception in thread Thread-2 (run_command): Traceback (most recent call last): File "/opt/anaconda3/envs/mindsearch/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/opt/anaconda3/envs/mindsearch/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/data/xyzliang/project/MindSearch/MindSearch/mindsearch/agent/mindsearch_agent.py", line 360, in run_command exec(cmd, globals(), self.local_dict) File "", line 10, in TypeError: WebSearchGraph.add_node() missing 1 required positional argument: 'node_content' INFO: 127.0.0.1:46356 - "POST /v1/completions HTTP/1.1" 200 OK 根据上海今天的天气情况,建议您穿着轻便舒适的衣服。根据[1],上海今天的气温预计在25°C到30°C之间,相对湿度较高,为70%左右。因此,建议您选择透气性好的衣物,如棉质或亚麻质地的衣服,以便在高温下保持凉爽。

此外,根据[2],今天上海可能会有阵雨,所以建议您随身携带雨伞或雨衣,以防不测。

综上所述,基于上海今天的天气预报,建议您穿着轻便舒适、透气性好的衣物,并随身携带雨具。这样既能保持身体的舒适度,又能应对可能的降雨情况。

INFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
INFO:     Finished server process [3134412]

进程已结束,退出代码为 0

如果将问题修改的复杂一些,会额外出现另两个报错,不影响最后出结果:

[TM][WARNING] [LlamaTritonModel] `max_context_token_num` = 32776.
2024-08-24 21:06:12,159 - lmdeploy - WARNING - get 483 model params
[TM][WARNING] Devicle 0 peer access Device 1 is not available.
[TM][WARNING] Devicle 0 peer access Device 2 is not available.
[WARNING] gemm_config.in is not found; using default GEMM algo
HINT:    Please open http://0.0.0.0:23333 in a browser for detailed api usage!!!
HINT:    Please open http://0.0.0.0:23333 in a browser for detailed api usage!!!
HINT:    Please open http://0.0.0.0:23333 in a browser for detailed api usage!!!
INFO:     Started server process [3136646]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:23333 (Press CTRL+C to quit)
INFO:     127.0.0.1:34858 - "GET /v1/models HTTP/1.1" 200 OK
Launched the api_server in process 3136646, user can kill the server by:
import os,signal
os.kill(3136646, signal.SIGKILL)
INFO:     127.0.0.1:34860 - "POST /v1/completions HTTP/1.1" 200 OK
 <|action_start|> <|interpreter|> 
```python
from search_engine import WebSearchGraph

# 初始化搜索图
graph = WebSearchGraph()

# 添加根节点
graph.add_root_node("Moscow Institute of Physics and Technology")

# 添加子问题节点
graph.add_node("country", "What country is Moscow Institute of Physics and Technology located in?")
graph.add_node("established", "When was Moscow Institute of Physics and Technology established?")
graph.add_node("overview", "What is the overview of Moscow Institute of Physics and Technology?")
graph.add_node("address", "What is the address of Moscow Institute of Physics and Technology?")

# 添加回复节点
graph.add_response_node()

# 添加边
graph.add_edge("root", "country")
graph.add_edge("root", "established")
graph.add_edge("root", "overview")
graph.add_edge("root", "address")

# 获取搜索结果
results = graph.search()

# 输出搜索结果
print(results)

current query: ## 主问题 Moscow Institute of Physics and Technology

当前问题

What country is Moscow Institute of Physics and Technology located in?

current query: ## 主问题 Moscow Institute of Physics and Technology

当前问题

When was Moscow Institute of Physics and Technology established?

INFO: 127.0.0.1:34868 - "POST /v1/completions HTTP/1.1" 200 OK current query: ## 主问题 Moscow Institute of Physics and Technology

当前问题

What is the overview of Moscow Institute of Physics and Technology?

current query: ## 主问题 Moscow Institute of Physics and Technology

当前问题

What is the address of Moscow Institute of Physics and Technology?

INFO: 127.0.0.1:34870 - "POST /v1/completions HTTP/1.1" 200 OK ERROR:mindsearch.agent.mindsearch_agent:Error executing code: 'WebSearchGraph' object has no attribute 'search' Traceback (most recent call last): File "/data/xyzliang/project/MindSearch/MindSearch/mindsearch/agent/mindsearch_agent.py", line 360, in run_command exec(cmd, globals(), self.local_dict) File "", line 25, in AttributeError: 'WebSearchGraph' object has no attribute 'search' Exception in thread Thread-2 (run_command): Traceback (most recent call last): File "/opt/anaconda3/envs/mindsearch/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/opt/anaconda3/envs/mindsearch/lib/python3.10/threading.py", line 953, in run self._target(*self._args, self._kwargs) File "/data/xyzliang/project/MindSearch/MindSearch/mindsearch/agent/mindsearch_agent.py", line 360, in run_command exec(cmd, globals(), self.local_dict) File "", line 25, in AttributeError: 'WebSearchGraph' object has no attribute 'search' INFO: 127.0.0.1:34880 - "POST /v1/completions HTTP/1.1" 200 OK INFO: 127.0.0.1:34890 - "POST /v1/completions HTTP/1.1" 200 OK 2024-08-24 21:06:32,204 - lmdeploy - WARNING - kwargs request_output_len is deprecated for inference, use GenerationConfig instead. ERROR:mindsearch.agent.mindsearch_agent:Error in model_stream_thread: not enough values to unpack (expected 2, got 1) Traceback (most recent call last): File "/data/xyzliang/project/MindSearch/MindSearch/mindsearch/agent/mindsearch_agent.py", line 148, in model_stream_thread for answer in agent.stream_chat( File "/data/xyzliang/project/MindSearch/MindSearch/mindsearch/agent/mindsearch_agent.py", line 46, in stream_chat for agent_return in super().stream_chat(message, File "/data/xyzliang/project/MindSearch/lagent/lagent/agents/internlm2_agent.py", line 312, in stream_chat name, language, action = self._protocol.parse( File "/data/xyzliang/project/MindSearch/lagent/lagent/agents/internlm2_agent.py", line 172, in parse message, action = message.split( ValueError: not enough values to unpack (expected 2, got 1) Based on the previous assistant message, I need to call the \"search\" function with the argument \"query\" set to \"Moscow Institute of Physics and Technology location\". This will allow me to collect information about the location of the institute. By doing so, I can provide a detailed and accurate answer to the user's question about the country where Moscow Institute of Physics and Technology is located. {"name": "BingBrowser.search", "parameters": {"query": "Moscow Institute of Physics and Technology location"}} 根据搜索结果,莫斯科物理技术学院成立于1951年。以下是支持这一事实的引用:\n\n1. 维基百科:莫斯科物理技术学院(俄语:Московский физико-технический институт)是一所位于俄罗斯莫斯科的公立研究型大学,成立于1951年。\n - 引用来源:1\n\n2. 莫斯科物理技术学院官方网站:该学院成立于1951年,是俄罗斯最古老和最著名的技术大学之一。\n - 引用来源:2\n\n综上所述,莫斯科物理技术学院成立于1951年。 根据搜索结果,莫斯科物理技术学院(Moscow Institute of Physics and Technology,简称MIPT)是一所位于俄罗斯莫斯科的著名高等教育机构。以下是关于MIPT的概述:\n\n1. 历史:MIPT成立于1951年,最初名为莫斯科物理技术学院,是俄罗斯联邦最古老和最著名的技术大学之一。\n\n2. 排名:MIPT在多个国际排名中表现出色,例如在2022年QS世界大学排名中,MIPT在物理与天文学领域排名全球第33位,在工程与技术领域排名全球第101-150位。\n\n3. 学术实力:MIPT以其在物理学、数学、计算机科学、工程学等领域的卓越研究而闻名。该学院拥有多个研究中心和实验室,如量子计算中心、纳米技术中心等。\n\n4. 教学质量:MIPT提供本科、硕士和博士级别的教育,其课程设置注重理论与实践相结合,培养学生的创新能力和解决问题的能力。\n\n5. 国际合作:MIPT与全球多所知名大学和研究机构建立了合作关系,如麻省理工学院、斯坦福大学、牛津大学等,为学生提供了广泛的国际交流机会。\n\n6. 校园设施:MIPT的校园位于莫斯科市郊,占地面积广阔,拥有现代化的教学楼、图书馆、实验室、体育设施等。\n\n7. 学生生活:MIPT为学生提供了丰富的课外活动和社团组织,如科技俱乐部、体育俱乐部、志愿者组织等,以促进学生的全面发展。\n\n8. 就业前景**:MIPT的毕业生在科技、工程、金融等领域具有很高的竞争力,许多校友在国内外知名企业、研究机构和政府部门担任重要职务。\n\n以上信息来源于[1]。

XYZliang commented 2 weeks ago

应该是自己不小心下错了模型,应该是internlm/internlm2_5-20b-chat,错误下载成了internlm2,经过测试internlm/internlm2_5-7b-chat正常,应该是你们的internlm2还没有对mindsearch场景做微调导致输出存在偏差。我接着尝试internlm/internlm2_5-20b-chat进行量化后使用看看,也给后面的朋友们一个提示,还是得用internlm2_5系类

XYZliang commented 2 weeks ago

经过测试,原版的internlm2.5系列模型不会出现错误,但是4bit量化后还是会出现 ValueError: not enough values to unpack (expected 2, got 1) 不知道是不是使用lmdeploy量化导致的能力受影响。 ①希望InternLM可以推出internlm2_5-20b-chat官方量化版本并避免这个问题,②或者让lmdeploy支持gguf系类模型(文档没看到相关信息,直接指定路径会报错),③或者让或者可以给出一些官方示例的微调文件,方便大家对模型再次微调,甚至是对其他第三方模型进行微调

Lambert6 commented 2 weeks ago

请问需要python的哪个版本

XYZliang commented 2 weeks ago

请问需要python的哪个版本

我用的是 3.10