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

威海好的网站建设公司哪家好上海外贸股票

威海好的网站建设公司哪家好,上海外贸股票,上海金山网站建设公司,计算机网络技术就业率在当前大语言模型(LLM)应用开发的背景下,一个关键问题是如何评估模型输出的准确性。我们需要确定哪些评估指标能够有效衡量提示(prompt)的效果,以及在多大程度上需要对提示进行优化。 为解决这一问题,我们将介绍一个基于双代理的RAG(检索增强生成)评估系统。该系统使用生成代理…在当前大语言模型(LLM)应用开发的背景下,一个关键问题是如何评估模型输出的准确性。我们需要确定哪些评估指标能够有效衡量提示(prompt)的效果,以及在多大程度上需要对提示进行优化。 为解决这一问题,我们将介绍一个基于双代理的RAG(检索增强生成)评估系统。该系统使用生成代理和反馈代理,基于预定义的测试集对输出进行评估。或者更简单的说我们使用一个模型来评估另外一个模型的输出。 在本文中将详细介绍如何构建这样一个RAG评估系统,并展示基于四种提示工程技术的不同结果,包括ReAct、思维链(Chain of Thought)、自一致性(Self-Consistency)和角色提示(Role Prompting)。 以下是该项目的整体架构图: 数据收集与摄入 此部分在 ingestion.py 中实现 数据收集过程使用了三篇文章作为源数据。在加载和分割数据后,我们对文本进行嵌入,并将嵌入向量存储在FAISS中。FAISS(Facebook AI Similarity Search)是由Meta开发的开源库,用于高效进行密集向量的相似性搜索和聚类。 以下是实现代码: urls [ https://medium.com/fareedkhandev/prompt-engineering-complete-guide-2968776f0431, https://medium.com/researchgraph/prompt-engineering-21112dbfc789, https://blog.fabrichq.ai/what-is-prompt-engineering-a-detailed-guide-with-examples-4d3cbbd53792 ] loaderWebBaseLoader(urls) # 文本分割器 text_splitterRecursiveCharacterTextSplitter( chunk_size1000, chunk_overlap20 ) documentsloader.load_and_split(text_splitter) # LLM embedder_llmOpenAIModel().embed_model() # 对文档块进行嵌入 vectorstoreFAISS.from_documents(documents, embedder_llm) vectorstore.save_local(faiss_embed) print( 数据摄入完成 )创建测试集 此部分在 create_test_set.py 中实现 测试集的构建使用了Giskard工具。Giskard是一个开源工具,专为测试和改进机器学习模型而设计。它使用户能够创建、运行和自动化测试,以评估模型的性能、公平性和稳健性。 实现代码如下: fromlangchain_community.document_loadersimportWebBaseLoader fromlangchain.text_splitterimportRecursiveCharacterTextSplitter # 用于构建测试集 fromgiskard.ragimportKnowledgeBase, generate_testset # 数据框 importpandasaspd fromLLM.modelsimportOpenAIModel if__name____main__: urls [ https://medium.com/fareedkhandev/prompt-engineering-complete-guide-2968776f0431, https://medium.com/researchgraph/prompt-engineering-21112dbfc789, https://blog.fabrichq.ai/what-is-prompt-engineering-a-detailed-guide-with-examples-4d3cbbd53792 ] loaderWebBaseLoader(urls) # 文本分割器 text_splitterRecursiveCharacterTextSplitter( chunk_size1000, chunk_overlap20 ) documentsloader.load_and_split(text_splitter) dfpd.DataFrame([doc.page_contentfordocindocuments], columns[text]) print(df.head(10)) ## 将数据框添加到giskard KnowledgeBase knowledge_baseKnowledgeBase(df) # 生成测试集 test_setgenerate_testset( knowledge_base, num_questions10, agent_descriptionA chatbot answering question about prompt engineering ) test_set.save(test-set.jsonl)由于文本太多生成的样例就不显示了 答案检索 此部分在 generation.py 中实现 本文的第一个流程是生成流程。我们从FAISS检索数据。实现代码如下 generate_llmOpenAIModel().generate_model() embedder_llmOpenAIModel().embed_model() vectorstoreFAISS.load_local(faiss_embed, embedder_llm, allow_dangerous_deserializationTrue) retrieval_qa_chat_prompt (retrieval) promptChatPromptTemplate.from_messages( [ (system, retrieval_qa_chat_prompt), (human, {input}), ] )combine_docs_chaincreate_stuff_documents_chain(generate_llm, prompt) retrival_chaincreate_retrieval_chain( retrievervectorstore.as_retriever(), combine_docs_chaincombine_docs_chain )评估 此部分在 evaluation.py 中实现 评估过程中向LLM提供三个输入问题、AI答案第一个LLM的输出和实际答案从测试集中检索。实现代码如下 defRAG_eval(question, AI_answer, Actual_answer, prompt): evaluation_prompt_templatePromptTemplate( input_variables[ question, AI_answer, Actual_answer ], templateprompt ) generate_llmOpenAIModel().generate_model() optimization_chainevaluation_prompt_template|generate_llm|StrOutputParser() result_optimizationoptimization_chain.invoke( {question: question, AI_answer: AI_answer, Actual_answer: Actual_answer}) returnresult_optimization链接整合 此部分在 main.py 中实现 主文件遍历测试数据使用问题作为第一个LLM的输入。然后将第一个LLM的输出用作第二个LLM的输入。实现代码如下 foritemindata: question {input: item[question]} # 生成回答 resultretrival_chain.invoke(inputquestion) AI_answerresult[answer] # 获取实际答案 Actual_answeritem[reference_answer] # 将所有内容提供给第二个LLM EvaluationRAG_eval( questionquestion, AI_answerAI_answer, Actual_answerActual_answer, promptevaluation_self_consistency_prompting ) print(fAI_answer:{AI_answer}) print(Evaluation)实验结果 评估组件采用了四种不同的提示工程技术 思维链Chain of ThoughtReAct角色提示Role Prompting自一致性Self-Consistency 以下是基于这四种不同提示技术的评估代理对测试集第一个问题的输出示例 问题 What is the purpose of incorporating knowledge in prompt engineering? 实际答案 Incorporating knowledge or information in prompt engineering enhances the model’s prediction accuracy. By providing relevant knowledge or information related to the task at hand, the model can leverage this additional context to make more accurate predictions. This technique enables the model to tap into external resources or pre-existing knowledge to improve its understanding and generate more informed responses **AI答案**Incorporating knowledge in prompt engineering enhances the quality of responses by guiding AI models to provide not just answers, but also relevant context and insights. This leads to more informative and meaningful interactions, improving user experience and understanding. 使用思维链输出的**评估结果**The student’s answer correctly identifies that incorporating knowledge enhances the quality of responses and improves user experience. However, it lacks emphasis on the model’s prediction accuracy and the importance of leveraging external resources or pre-existing knowledge, which are key components of the actual answer. This omission affects the completeness and correctness of the response. 使用ReAct输出的评估结果****The student’s answer correctly identifies that incorporating knowledge enhances the quality of responses and improves user experience. However, it lacks emphasis on the specific aspect of prediction accuracy and the importance of leveraging external resources or pre-existing knowledge, which are key components of the actual answer. This omission affects the completeness of the response, leading to a lower evaluation percentage. 使用角色提示输出的评估结果****The student’s response accurately captures the essence of incorporating knowledge in prompt engineering by emphasizing the enhancement of response quality and user experience. However, it lacks specific mention of prediction accuracy and the model’s ability to leverage external resources, which are key aspects of the actual response. 使用自一致性输出的评估结果****The student’s answer captures the essence of enhancing the quality of responses through knowledge incorporation, but it lacks specific mention of prediction accuracy and the model’s ability to leverage external resources. The initial evaluation was slightly optimistic, but upon reevaluation, it became clear that the answer did not fully align with the actual answer’s emphasis on prediction accuracy and context utilization 实验结果分析 下图展示了四种提示工程技术的准确性比较。每种技术由图中的一条独立线条表示X轴上的10个数据点对应测试数据的索引值Y轴表示准确性值。 在评估过程中准确性达到85%及以上的响应视为真正准确True低于85%则视为不准确False。下面的条形图展示了基于每种提示工程技术的评估结果中True和False的计数。 实验结果显示ReAct和思维链Chain of Thought的性能几乎相似而自一致性Self-Consistency则表现出完全相反的行为。角色提示Role Prompting在所有方法中表现最不稳定。 一些发现 评估代理的所有响应虽然在内容上相近都提到了类似的缺失元素但反馈之间的差异主要体现在具体措辞和强调点上这些细微差别可能会对最终的评分过程产生影响。角色提示和自一致性技术倾向于强调结果的积极方面而ReAct和思维链则更多地使用特定措辞来突出回答中的缺失部分。 总结 本文展示了如何构建一个基于双代理的RAG检索增强生成评估系统该系统使用两个大语言模型LLM一个用于生成响应另一个用于提供反馈。通过采用四种不同的提示工程技术——思维链、ReAct、角色提示和自一致性我们能够全面评估AI生成响应的准确性和质量。 实验结果表明 ReAct和思维链技术在性能上表现相似这可能是因为它们都强调了结构化思考过程。自一致性技术经常产生与其他方法相反的结果这突显了在评估过程中考虑多个角度的重要性。角色提示技术被证明是最不可靠的这可能是由于其在不同上下文中的不一致性。 本文代码 https://avoid.overfit.cn/post/f64e1de74d8a423a859086dfed4d5a47 作者Homayoun S.
http://www.w-s-a.com/news/632651/

相关文章:

  • 网站建设的内容下拉网站导航用ps怎么做
  • 怎样做p2p网站海口免费自助建站模板
  • 给企业建设网站的流程图wordpress 添加子菜单
  • 企业网站带新闻发布功能的建站皋兰县建设局网站
  • 国内外做gif的网站wordpress数据库教程
  • 成都建站平台自己做一个网站需要多少钱
  • 景区旅游网站平台建设公司企业网站源码
  • 免费高清网站推荐喂来苏州网络科技有限公司
  • php做的大型网站有哪些备案博客域名做视频网站会怎么样
  • 去哪网站备案吗昭通网站建设
  • flash企业网站源码建筑材料采购网站
  • 网站可以换虚拟主机吗部门做网站优点
  • 如何做分类网站信息营销莱芜网页定制
  • 班级网站建设感想中国做视频网站有哪些
  • 做刷票的网站wordpress图片链接插件
  • 给客户做网站图片侵权沈阳做网站的地方
  • 网站开发步骤规划蓝天云免费空间主机
  • 网站字体规范wordpress找不到页面内容编辑
  • 静态网站建设参考文献茂名营销型网站制作公司
  • 君山区建设局网站风铃微网站怎么做
  • 购物网站销售管理合肥网络推广平台
  • 网站建设规划书txt微盘注册帐号
  • 小说网站开发实训报告企业网盘收费标准
  • mvc网站开发医疗医院网站建设
  • 天津市建设厅官方网站wordpress设置404
  • 贵阳好的网站建设免费正能量网站下载ww
  • 免费学习的网站平台自建站seo如何做
  • 海南三亚做网站公众号版面设计创意
  • 学校网站建设目的与意义合肥网页定制
  • 网站查询地址网站建设与维护费用