当前位置: 首页 > news >正文

电子商务网站建设详细策划书外贸营销网站

电子商务网站建设详细策划书,外贸营销网站,外贸网站建设哪家实惠,品牌建设情况评估背景 楼主决定提升与LLM交互的质量,之前是直接prompt->answer的范式,现在我希望能用上ReAct策略和能够检索StackOverflow,让同一款LLM发挥出更大的作用。 难点 1. 怎样调用StackOverflow step1 pip install stackspi step 2 from la…

背景

楼主决定提升与LLM交互的质量,之前是直接prompt->answer的范式,现在我希望能用上ReAct策略和能够检索StackOverflow,让同一款LLM发挥出更大的作用。

难点

1. 怎样调用StackOverflow

step1 pip install stackspi

step 2

from langchain.agents import load_toolstools = load_tools(["stackexchange"],llm=llm
)

注:stackoverflow是stackexchange的子网站 

2. 交互次数太多token输入超出了llm限制

approach 1 使用ConversationSummaryBufferMemory

这种记忆方式会把之前的对话内容总结一下,限制在设定的token个数内

from langchain.memory import ConversationSummaryBufferMemorymemory = ConversationSummaryBufferMemory(llm = llm, # 这里的llm的作用是总结max_token_limit=4097,memory_key="chat_history"
)

approach 2 设置参数max_iterations

agent = ZeroShotAgent(llm_chain=llm_chain, tools=tools, max_iterations=4, # 限制最大交互次数,防止token超过上限verbose=True
)

3. llm总是回复无法回答

很多教程把温度设置成0,说是为了得到最准确的答案,但是我发现这样设置,agent会变得特别谨慎,直接说它不知道,温度调高以后问题解决了。

测试问题

What parts does a JUnit4 unit test case consist of?

代码

from constants import PROXY_URL,KEYimport warnings
warnings.filterwarnings("ignore")import langchain
langchain.debug = Truefrom langchain.agents import load_tools
from langchain.chat_models import ChatOpenAIfrom langchain.agents import AgentExecutor, ZeroShotAgent
from langchain.chains import LLMChain
from langchain.memory import ConversationSummaryBufferMemoryllm = ChatOpenAI(temperature=0.7, # 如果参数调得很低,会导致LLM特别谨慎,最后不给答案model_name="gpt-3.5-turbo-0613", openai_api_key=KEY,openai_api_base=PROXY_URL
)memory = ConversationSummaryBufferMemory(llm = llm, # 这里的llm的作用是总结max_token_limit=4097,memory_key="chat_history"
)prefix = """You should be a proficient and helpful assistant in java unit testing with JUnit4 framework. You have access to the following tools:"""
suffix = """Begin!"{chat_history}
Question: {input}
{agent_scratchpad}"""tools = load_tools(["stackexchange"],llm=llm
)prompt = ZeroShotAgent.create_prompt(tools,prefix=prefix,suffix=suffix,input_variables=["input", "chat_history", "agent_scratchpad"],
) # 这里集成了ReActllm_chain = LLMChain(llm=llm, prompt=prompt)agent = ZeroShotAgent(llm_chain=llm_chain, tools=tools, max_iterations=4, # 限制最大交互次数,防止token超过上限verbose=True
)agent_chain = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True, memory=memory
)def ask_agent(question):answer = agent_chain.run(input=question)return answerdef main():test_question = "What parts does a JUnit4 unit test case consist of?"test_answer = ask_agent(test_question)return test_answerif __name__ == "__main__":main()

最后输出

[chain/end] [1:chain:AgentExecutor] [75.12s] Exiting Chain run with output:
{
  "output": "A JUnit4 unit test case consists of the following parts:\n1. 
Test class: This is a class that contains the test methods.\n2. Test methods: These are the methods that contain the actual test code. They are annotated with the @Test annotation.\n3. Assertions: These are used to verify 
the expected behavior of the code being tested. JUnit provides various assertion methods for this purpose.\n4. Annotations: JUnit provides several annotations that can be used to configure the test case, such as @Before, @After, @BeforeClass, and @AfterClass.\n\nOverall, a JUnit4 unit test case 
is a class that contains test methods with assertions, and can be configured using annotations."
}

http://www.hotlads.com/news/256.html

相关文章:

  • 做一个商城网站教育培训排行榜前十名
  • 邢台有限公司高级seo培训
  • 做网站需要规划好什么网站优化seo推广服务
  • 西安网站开发的空间竞价推广公司
  • 信息化建设办公室网站百度seo优化排名
  • b2c网站设计seo个人博客
  • 建个公司网站怎么弄互联网公司排名
  • html5 网站开发工具实体店怎么引流推广
  • 丹东谁做微网站深圳百度网站排名优化
  • 网站改版怎么做301重定向平台运营
  • 专门做评测的网站有哪些网络服务包括哪些内容
  • 建设公司网站标题口碑营销的缺点
  • 福建建设执业管理中心网站网站优化策划书
  • 做电商网站搭建就业岗位seo知名公司
  • 做内部网站费用发广告平台有哪些免费
  • wordpress 开启手机seo国外英文论坛
  • 网站建设合同 包括什么企业seo优化服务
  • 核工业华南建设集团网站整站排名优化品牌
  • 银行网站建设方案站长工具seo综合查询5g
  • 网站建设赚钱项目新闻稿
  • 网站开发要什么软件如何在互联网上做推广
  • 苹果app开发软件厦门谷歌seo公司有哪些
  • 杭州个人做网站广告词
  • 深圳罗湖做网站58旅游搜索量环比增188%
  • 案例学网页设计和网站建设如何制作网页教程
  • 电子商务网站开发需求文档南通百度seo代理
  • 网站制作小工具我想做网络推广找谁
  • 合川网站建设深圳网络公司推广公司
  • 好看的个人网站主页江北seo页面优化公司
  • 找建筑图纸的网站品牌策划ppt案例