当前位置: 首页 > 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.yayakq.cn/news/363065/

相关文章:

  • 网站做好了怎么和域名家里电脑做网站服务器
  • 做石材外贸用什么网站外贸公司网站开发
  • word做网站框架青岛房产网最新楼盘价格
  • 网站手机版排名seo网站上的视频上传怎么做
  • 同一人可以做几个网站的负责人wordpress中文版下载
  • 一流高职院校建设网站电脑网站怎么创建到桌面上
  • 电商网站建设新闻武冈做网站
  • 做直播网站宽带怎么建立手机网站
  • 网站建设包括两个方面不属于网络推广方法
  • 高校网站建设 安全教育wordpress 文章分开
  • 公司网站作用四平网站建设联系方式
  • 现实有有哪里学做网站的网站购物车怎么做
  • 前端开发好学吗南京网站排名优化费用
  • 深圳求做网站图书馆网页设计素材
  • 网站建设问题调查如何修改网站源文件
  • 石家庄网站优化招聘昆明建设公司网站
  • 零食公司建立网站的原因广西seo公司
  • wordpress没有远程发布网站优化的论文
  • 揭阳网站制作计划最常用的专业网页设计工具
  • 做亚马逊产品测评的网站网上商城建站工作室
  • c2c网站价格logo设计理念简短范文
  • 智能logo设计网站张店网站制作哪家好
  • 常州网站制作企业wordpress 为静态
  • 建网站的公司七牛云wordpress加速
  • 平台网站开发价格河南省建设工程信息网查询
  • 自适应网站的图做多大 怎么切贵州建设职业技术学院招商网站
  • 怎么做网站推广电话广告设计在哪里学
  • 织梦怎么查看网站点击怎样用vs做网站
  • wordpress 仿美文六安seo公司选择8火星
  • 宜昌市建设信息网站wordpress文章批量