以下是关于文档问答的系统知识:
在使用 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[1]" 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.
此外,还有以下建议:
[title]VIRTUALClaude官方文档提示词工程最佳实践@未来力场编译版(中英对照)[heading2]Use examples[heading3]What makes a good example?[heading4]For tasks with many● Tell Claude to read the document carefully because it will be asked questions later● For document Q&A,ask the question at the end of the prompt after other input information(there is a large quantitatively measured difference in quality of result)● Tell Claude to find quotes relevant to the question first before answering and answer only if it finds relevant quotes● Give Claude example question + answer pairs that have been generated from other parts of the queried text(either by Claude or manually)Generic examples on general/external knowledge do not seem to help performance.For further information,see Anthropic’s blog post on prompt engineering for Claude’s long context window高级提示词技巧提示词链10万上下文一个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[1]"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.<examples>
When using Claude for document question-answering tasks,keep these tips in mind:在使用克劳德进行文档问答任务时,请记住以下建议:Place the question at the end of the prompt,after the input data.As mentioned,this has been shown to significantly improve the quality of Claude's responses.将问题放在提示的末尾,在输入数据之后。如前所述,这已经被证明显著改善了克劳德的回答质量。Ask Claude to find quotes relevant to the question before answering,and to only answer if it finds relevant quotes.This encourages Claude to ground its responses in the provided context and reduces hallucination risk.要求克劳德在回答之前找到与问题相关的引语,并且只有在找到相关引语时才回答。这鼓励克劳德将其回答扎根于所提供的背景,并且减少了幻觉风险。Instruct Claude to read the document carefully,as it will be asked questions later.This primes Claude to pay close attention to the input data with an eye for the task it will be asked to execute.指示克劳德仔细阅读文件,因为稍后会有问题。这使克劳德能够密切关注输入数据,以便能够执行后续的任务。Here's an example prompt that incorporates these tips:这里有一个示例提示,结合了这些提示:
让Claude根据一段文字回答问题相对简单(如基本文本分析所示)。而让Claude以特定格式回答带有引用来源的问题则比较复杂。查找文本中相关引用,回答问题并引用来源的提示:人类:我将给你一份文档。然后我会问你一个关于它的问题。我希望你首先摘录文档中有助于回答问题的部分的确切引用,然后用摘录的内容回答问题。这是文档:<document>{{TEXT}}</document>以下是第一个问题:{{QUESTION}}首先,找出文档中对回答问题最相关的引用,并按编号顺序列出。引用应该相对较短。如果没有相关引用,请写“无相关引用”。然后,回答问题,以"回答:"开始。回答中不要直接包含或引用引用的内容。回答时不要说“根据引用[1]”。相反,只需在相关句子的末尾添加方括号内的编号,引用与答案的各部分相关联。因此,你的整体回应的格式应该像<example></example>标签之间显示的内容一样。确保严格遵循格式和间距。<example>相关引用:[1]"公司X在2021年报告了1200万美元的营收。"[2]"近90%的营收来自小部件销售,而小工具销售占了剩下10%。"