- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Langchain 和特定 URL 作为源数据来整理一个简单的“带有来源的问答”。该 URL 由一个页面组成,其中包含大量信息。
问题是 RetrievalQAWithSourcesChain
只给我返回整个 URL 作为结果的来源,这在这种情况下不是很有用。
有没有办法获得更详细的源信息?也许页面上特定部分的标题?指向页面正确部分的可点击 URL 会更有帮助!
我有点不确定结果源
的生成是语言模型、URL加载器的函数还是仅仅是RetrievalQAWithSourcesChain
的函数。
我尝试过使用 UnstructedURLLoader
和 SeleniumURLLoader
,希望更详细的数据读取和输入会有所帮助 - 遗憾的是没有。
相关代码摘录:
llm = ChatOpenAI(temperature=0, model_name='gpt-3.5-turbo')
chain = RetrievalQAWithSourcesChain.from_llm(llm=llm, retriever=VectorStore.as_retriever())
result = chain({"question": question})
print(result['answer'])
print("\n Sources : ",result['sources'] )
最佳答案
ChatGPT 非常灵活,越明确,您可以获得的结果越好。 This link show the docs for the function you are using 。 langchain.prompts.BasePromptTemplate 有一个参数,可让您向 ChatGPT 提供更明确的指令。
看起来基本提示模板是这样的
Use the following knowledge triplets to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.\n\n{context}\n\nQuestion: {question}\nHelpful Answer:
您可以添加另一句话,为 ChatGPT 提供更清晰的说明
Please format the answer with JSON of the form { "answer": "{your_answer}", "relevant_quotes": ["list of quotes"] }. Substitutde your_answer as the answer to the question, but also include relevant quotes from the source material in the list.
您可能需要稍微调整一下才能使 ChatGPT 良好响应。然后你应该能够解析它。
ChatGPT API 中有 3 种消息类型
我强烈推荐这些courses在 ChatGPT 上,因为它们来自 Andrew Ng 并且质量非常高。
关于python - 如何使用 Langchain 获得更详细的结果来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76482024/
尝试运行 langchain 的基本教程脚本时遇到此错误: ModuleNotFoundError: No module named 'langchain.llms'; 'langchain' is
尝试运行 langchain 的基本教程脚本时遇到此错误: ModuleNotFoundError: No module named 'langchain.llms'; 'langchain' is
目录 简介 好的prompt 什么是prompt template 在langchain中创建prompt temp
我想我不明白代理如何选择工具。我有一个矢量数据库(Chroma),其中嵌入了我希望代理首先查看的所有内部知识。然后,如果答案不在 Chroma 数据库中,它应该使用 OpenAI 用于训练的信息(外部
我正在尝试使用 langchain 代理为软件工程师生成一个月的面试计划。期望代理应该询问用户几个问题并制定计划。 import os from langchain.memory import Con
我用 langchain 库构建了一个分割器函数,可以分割一系列 python 文件。在代码中的另一点,我需要将这些文档转换回 python 代码。只是我不知道该怎么做 def index_repo(
我正在使用 Langchain 的 RecursiveCharacterTextSplitter 来分割 python 文件。这样做我会丢失哪个 block 属于哪个文件的信息。之后如何跟踪各个 bl
希望你做得很好。我根据以下 langchain 文档准备了一个聊天机器人: Langchain chatbot documentation 在上面的langchain文档中,提示模板有两个输入变量——
我在Python中使用带有Gradio接口(interface)的Langchain。我制作了一个对话代理,并尝试将其响应传输到 Gradio 聊天机器人界面。我查看了 Langchain 文档,但找
我正在尝试使用 Langchain 和特定 URL 作为源数据来整理一个简单的“带有来源的问答”。该 URL 由一个页面组成,其中包含大量信息。 问题是 RetrievalQAWithSourcesC
希望你做得很好。我根据以下 langchain 文档准备了一个聊天机器人: Langchain chatbot documentation 在上面的langchain文档中,提示模板有两个输入变量——
我在Python中使用带有Gradio接口(interface)的Langchain。我制作了一个对话代理,并尝试将其响应传输到 Gradio 聊天机器人界面。我查看了 Langchain 文档,但找
我正在尝试使用 Langchain 和特定 URL 作为源数据来整理一个简单的“带有来源的问答”。该 URL 由一个页面组成,其中包含大量信息。 问题是 RetrievalQAWithSourcesC
我想我不明白代理如何选择工具。我有一个矢量数据库(Chroma),其中嵌入了我希望代理首先查看的所有内部知识。然后,如果答案不在 Chroma 数据库中,它应该使用 OpenAI 用于训练的信息(外部
我正在尝试使用 langchain 代理为软件工程师生成一个月的面试计划。期望代理应该询问用户几个问题并制定计划。 import os from langchain.memory import Con
我用 langchain 库构建了一个分割器函数,可以分割一系列 python 文件。在代码中的另一点,我需要将这些文档转换回 python 代码。只是我不知道该怎么做 def index_repo(
我正在使用 Langchain 的 RecursiveCharacterTextSplitter 来分割 python 文件。这样做我会丢失哪个 block 属于哪个文件的信息。之后如何跟踪各个 bl
我正在开发一个使用 SvelteKit 和 Langchain 的项目。我想实现一个功能,我可以按下按钮并让 UI 在聊天流进入时显示它们的标记。但是,我当前使用表单操作的实现遇到了一些困难。 这是我
我正在关注langchain官方文档here中的本教程我是否尝试在使用时跟踪 token 的数量。但是,我想使用 gpt-3.5-turbo 而不是 text-davinci-003,因此我将使用的
我想创建一个自托管的 LLM 模型,该模型将能够拥有我自己的自定义数据的上下文(就此而言,Slack 对话)。 我听说 Vicuna 是 ChatGPT 的一个很好的替代品,所以我编写了以下代码: f
我是一名优秀的程序员,十分优秀!