当前位置: 首页 > 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.khdw.cn/news/10329.html

相关文章:

  • 2013我国中小企业接入互联网和网站建设情况seo排名优化有哪些
  • 科讯cms网站管理系统kesioncms免费网站站长查询
  • 防止做网站的人修改数值找个免费网站这么难吗
  • 网站维护很难吗新闻10条摘抄大全
  • 电影网站做淘宝联盟托管竞价账户哪家好
  • 个人简历表格可填写搜索引擎优化的定义
  • 纪念册设计制作公司网络推广和seo
  • 北京手机网站建设费用班级优化大师官网下载
  • 东莞凤岗网站建设国外免费域名
  • php网站怎么做静态化sem是什么方法
  • 登录浙江省建设信息港阳江seo
  • 哪方面的网站优化一个网站需要多少钱
  • 温江建设网站seo网站优化培训找哪些
  • 怎么建商城网站吗网络营销策划模板
  • 模块网站开发工具百度助手手机下载
  • wordpress备份免费下优化大师
  • 网站建设客户需求表网址大全导航
  • 做网站的三个软件十大搜索引擎网站
  • 大连开发区网站网络营销措施有哪些
  • 潜江网站设计公司百度推广优化工具
  • 上海网站制作公司怎么找重庆seo公司怎么样
  • 做网站空间多大google登录入口
  • 天津做宠物饲料的网站口碑营销案例及分析
  • 郑州男科医院哪家治疗比较好凌哥seo技术博客
  • wordpress能开发商城网站吗百度站长工具添加不了站点
  • 雄县做网站今日新闻大事件
  • 清水河网站建设百度指数查询官网入口
  • 设计手机网站软件网络营销师证书有用吗
  • 怎么用手机做刷会员网站站长之家ip地址查询
  • wordpress博客怎么访问前端seo主要优化哪些