FeiLiu36 / EoH

Evolution of Heuristics
MIT License
57 stars 6 forks source link

在运行本地大模型时,是否还需要llm_api_endpoint和llm_api_key参数? #3

Closed veresse closed 1 month ago

veresse commented 1 month ago

老师您好,我在本地复现过程中出现了一点问题,现在有一些问题想向您请教一下,我选择在本地部署了gemma-2b,在运行local_problem的runEOH.py代码时为什么还需要输入api_endpoint和api_key,修改了llm_use_local为True和本地的url还是无法运行,请您指教一下。期待您的回复

RayZhhh commented 1 month ago

您好!谢谢您关注这个工作并报告代码问题!如果您使用本地部署的LM/LLM,就不需要输入api_endpoint和api_key了,可以将其设置为None。如果您修改了use_local_llm=True, 并设置了url,理论上是可以正常运行的。请问您是否方便提供更多的细节,如:

  1. 您运行EoH是否有输出,输出的内容是什么?
  2. 如果您将gemma-2b部署在了一个服务端,服务端是否有输出?如有,能否展示一下输出的内容? 谢谢!

另外,对于local_problem的runEOH.py代码时为什么还需要输入api_endpoint和api_key,我们正在优化代码框架并整合一个更加通用的,并包含更多算法的平台,谢谢您的反馈!

veresse commented 1 month ago

老师,您好,非常感谢您能在百忙之中抽出时间回答我的问题。我在本地下载gemma-2b后,按照步骤运行了 python gemma_instruct_server.py后,得到了url,在运行local_problem的runEOH.py时,如果将api_endpoint和api_key注释掉或者不修改api_endpoint和api_key时,就会输出错误提示,提示我应该输入正确的api_endpoint和api_key。如果我将api_endpoint和api_key和置为None的话,就会输出api_endpoint和api_key只能为str类型。下边分别是两种结果。的截图,希望您解答一下我的问题,非常感谢。

在 2024-05-14 14:00:18,"RayZhhh" @.***> 写道:

您好!谢谢您关注这个工作并报告代码问题!如果您使用本地部署的LM/LLM,就不需要输入api_endpoint和api_key了,可以将其设置为None。如果您修改了use_local_llm=True, 并设置了url,理论上是可以正常运行的。请问您是否方便提供更多的细节,如:

您运行EoH是否有输出,输出的内容是什么? 如果您将gemma-2b部署在了一个服务端,服务端是否有输出?如有,能否展示一下输出的内容? 谢谢!

另外,对于local_problem的runEOH.py代码时为什么还需要输入api_endpoint和api_key,我们正在优化代码框架并整合一个更加通用的,并包含更多算法的平台,谢谢您的反馈!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

RayZhhh commented 1 month ago

抱歉我好像通过邮件和网页都看不到您贴的图片😂

veresse commented 1 month ago

好的,老师,那我将图片中的内容以文字形式显示:我在本地下载gemma-2b后,按照步骤运行了 python gemma_instruct_server.py后,得到了url,在运行local_problem的runEOH.py时,如果将api_endpoint和api_key注释掉或者不修改api_endpoint和api_key时,就会输出错误提示:"(eoh) @.***:/mnt/d/CTR/EoH/examples/local_problem$ python runEoH.py

{'Weibull 5k': 1987.8}


--- Start EoH ---


Stop with wrong API setting: Set api_endpoint (e.g., api.chat...) and api_key (e.g., kx-...) !"

提示我应该输入正确的api_endpoint和api_key。

如果我将api_endpoint和api_key和置为None的话,就会输出错误提示:输出api_endpoint和api_key只能为str类型。"TypeError: can only concatenate str (not "NoneType") to str"

希望您解答一下我的问题,非常感谢。

在 2024-05-14 15:21:38,"RayZhhh" @.***> 写道:

抱歉我好像通过邮件和网页都看不到您贴的图片

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

FeiLiu36 commented 1 month ago

您好! 我们更新了针对local LLM 的代码框架。请尝试最新的 example with local llm

                llm_use_local = True, # set your LLM endpoint
                llm_local_url = "http://xxx/completions",   # set your url for local deployment

另外,对于一般使用者我们推荐使用远程的API来调用,本地local llm inference 会导致设计效率大大降低。或者将local llm 部署在服务器中。 谢谢!

veresse commented 1 month ago

非常感谢您对我提出的问题进行的回复,我后续会考虑您的建议,非常感谢

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2024年05月19日 18:42 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [FeiLiu36/EoH] 在运行本地大模型时,是否还需要llm_api_endpoint和llm_api_key参数? (Issue #3) |

您好! 我们更新了针对local LLM 的代码框架。请尝试最新的 example with local llm。

            llm_use_local = True, # set your LLM endpoint
            llm_local_url = "http://xxx/completions",   # set your url for local deployment

另外,对于一般使用者我们推荐使用远程的API来调用,本地local llm inference 会导致设计效率大大降低。或者将local llm 部署在服务器中。 谢谢!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

RayZhhh commented 1 month ago

请您尝试修改过的 gemma_instruct_server.py,之前的版本有些问题,现在已经更新,如有问题请随时交流,再次感谢!👍

veresse commented 1 month ago

收到,非常感谢您对我的意见进行的回复。

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2024年05月20日 19:11 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [FeiLiu36/EoH] 在运行本地大模型时,是否还需要llm_api_endpoint和llm_api_key参数? (Issue #3) |

请您尝试修改过的 gemma_instruct_server.py,之前的版本有些问题,现在已经更新,如有问题请随时交流,再次感谢!👍

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

veresse commented 1 month ago

尊敬的作者,您好,我听从您的建议后,更换为远程API调用模型,可是无论我是用谷歌的gemini还是deepseek,在运行bp_online 时,运行后都会卡在这里:(eoh) @.***:/mnt/d/EoH/examples/bp_online$ python runEoH.py

--- Start EoH ---

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2024年05月20日 19:11 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [FeiLiu36/EoH] 在运行本地大模型时,是否还需要llm_api_endpoint和llm_api_key参数? (Issue #3) |

请您尝试修改过的 gemma_instruct_server.py,之前的版本有些问题,现在已经更新,如有问题请随时交流,再次感谢!👍

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

FeiLiu36 commented 1 month ago

您好,我们刚刚测试了相同的example, 是可以正常运行的,如下是我们的terminal 输出:

PS D:\github\EoH_developer\examples\bp_online> python .\runEoH.py
-----------------------------------------
---              Start EoH            ---
-----------------------------------------
- output folder created -
-  parameters loaded -
{'Weibull 5k': 1987.8}
- Prob bp_online loaded
- EoH parameters loaded -
- Evolution Start -
- check LLM API
remote llm api is used ...
creating initial population:
Pop initial:
 Obj:  0.04226| Obj:  0.13211| Obj:  1.51534|
initial population has been created!

建议检查如下几项:

  1. 使用最新的EoH code
  2. 使用example/bp_online, 而不是example/bp_online_localLLM 谢谢!
veresse commented 1 month ago

您好,我检查了代码,还从git上重新拉取了项目,在运行bp_online的runeoh.py时还是一样的错误,我打印了llm_use_local后发现无论修改哪里的值,都打印的是True,我只能在runeoh里直接给llm_use_local赋值为false,请问这个llm_use_local的值是getparas的paras直接传递的吗?

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2024年05月23日 18:19 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [FeiLiu36/EoH] 在运行本地大模型时,是否还需要llm_api_endpoint和llm_api_key参数? (Issue #3) |

您好,我们刚刚测试了相同的example, 是可以正常运行的,如下是我们的terminal 输出:

PSD:\github\EoH_developer\examples\bp_online>python .\runEoH.py--------------------------------------------StartEoH---------------------------------------------outputfoldercreated--parametersloaded- {'Weibull 5k': 1987.8} -Probbp_onlineloaded-EoHparametersloaded--EvolutionStart--checkLLMAPIremotellmapiisused ... creatinginitialpopulation: Popinitial: Obj: 0.04226|Obj: 0.13211|Obj: 1.51534|initialpopulationhasbeencreated!

建议检查如下几项:

使用最新的EoH code 使用example/bp_online, 而不是example/bp_online_localLLM 谢谢!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

FeiLiu36 commented 1 month ago

请问这个llm_use_local的值是getparas的paras直接传递的吗?

是的

我打印了llm_use_local后发现无论修改哪里的值,都打印的是True,我只能在runeoh里直接给llm_use_local赋值为false

请看getParas.py, line 24, use_local_llm的默认设置是False

veresse commented 1 month ago

好的,感谢您的回复,现在可以运行了,我再去研究一下代码😂

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2024年05月23日 23:39 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [FeiLiu36/EoH] 在运行本地大模型时,是否还需要llm_api_endpoint和llm_api_key参数? (Issue #3) |

请问这个llm_use_local的值是getparas的paras直接传递的吗?

是的

我打印了llm_use_local后发现无论修改哪里的值,都打印的是True,我只能在runeoh里直接给llm_use_local赋值为false

请看getParas.py, line 24, use_local_llm的默认设置是False

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>