以下是关于文档问答的系统知识:
在使用 Claude 进行文档问答任务时,有以下要点:
1. 告诉 Claude 仔细阅读文档,因为稍后会被提问。
2. 对于文档问答,将问题置于提示的末尾,在其他输入信息之后(这在结果质量上有较大的定量差异)。
3. 要求 Claude 在回答之前先找到与问题相关的引语,只有找到相关引语时才进行回答。
4. 给 Claude 提供从被查询文本的其他部分生成的示例问题和答案对(可以由 Claude 生成或手动生成)。通用的外部知识示例似乎对性能没有帮助。有关更多信息,请参阅 Anthropic 的关于 Claude 长上下文窗口的提示工程博客文章。
一个 10 万上下文长度的提示词案例:
Human: I'm going to give you a document. Read the document carefully, because I'm going to ask you a question about it. Here is the document: <document>{{TEXT}}</document>
First, find the quotes from the document that are most relevant to answering the question, and then print them in numbered order. Quotes should be relatively short. If there are no relevant quotes, write "No relevant quotes" instead.
Then, answer the question, starting with "Answer:". Do not include or reference quoted content verbatim in the answer. Don't say "According to Quote" when answering. Instead make references to quotes relevant to each section of the answer solely by adding their bracketed numbers at the end of relevant sentences.
Thus, the format of your overall response should look like what's shown between the <examples></examples> tags. Make sure to follow the formatting and spacing exactly.
此外,还有以下建议:
1. 将问题放在提示的末尾,在输入数据之后。这已被证明显著改善了 Claude 的回答质量。
2. 要求 Claude 在回答之前找到与问题相关的引语,并且只有在找到相关引语时才回答。这鼓励 Claude 将其回答扎根于所提供的背景,并且减少了幻觉风险。
3. 示例提示:人类:我将给您一份文档。然后我会问您一个关于它的问题。我希望您首先摘录文档中有助于回答问题的部分的确切引用,然后用摘录的内容回答问题。这是文档: <document>{{TEXT}}</document> 以下是第一个问题: {{QUESTION}} 首先,找出文档中对回答问题最相关的引用,并按编号顺序列出。引用应该相对较短。如果没有相关引用,请写“无相关引用”。然后,回答问题,以“回答:”开始。回答中不要直接包含或引用引用的内容。回答时不要说“根据引用"近 90%的营收来自小部件销售,而小工具销售占了剩下 10%。"
2024-09-19