AI Personal Learning
and practical guidance
CyberKnife Drawing Mirror

Anthropic Prompts Engineering Course - Chapter 9: Complex Prompts for Legal Services

academic program

Input prompts in the legal industry can be quite complexThis is due to the need to.

  • Parsing long documents
  • Dealing with complex subjects
  • Formatting output in a very specific way
  • Follow a multi-step analysis process

Let's see how we can use a complex input prompt template to build input prompts for specific legal use cases.


typical example

Below, we detail a sample input prompt for a legal use case, in which we ask for Claude Answer questions that have legal issues. (We recommend that you scroll to the bottom to see the inputs we asked Claude to process, and then study the input prompts we wrote). We've changed the order of some of the elements so that the structure of the input prompt can be flexible!

Input Hints Engineering is about trial and error in scienceWe encourage you to mix and match. We encourage you to mix and match, move elements around (for elements where order is not important), and see what works best for you and your needs.

Prompt Element descriptive typical example note
1. "User:" formatting Start your CLAUDEMESSAGES() prompt with "User:". User. This is mandatory! It is always required to start with this when using the CLAUDEMESSAGES() prompt.
2. Background to the mandate Give Claude background on the role it should play or the goals and tasks you want it to accomplish. You're an expert lawyer. It is best to place the background at the beginning part of the prompt.
3. Tonal context If it is important in the interaction, tell Claude the tone he should use. This element may not be necessary depending on the task.
4. Input data If Claude needs to process data from a prompt, include the data within the relevant XML tag. Multiple data items can be included, but each should be placed within its own XML tag. "This is some compiled research data. Use it to answer users' legal questions. {{LEGAL_RESEARCH}}" When the input data is long, it is best to place it before the instruction.
5. Examples Provide at least one example of an ideal response for Claude to emulate. Enclose in XML tags. Multiple examples can be provided, with context for each. "When citing legal research, use parentheses containing the search index ID followed by a period. Place these at the end of the cited sentence. EXAMPLE: The statute of limitations for this offense is 10 years. [3] However, the protection does not apply when the parties have expressly waived it. [5]" Examples are probably the most effective tool for getting Claude to work with the desired behavior. Be sure to provide examples of common edge cases. Example drafts work better if draft paper is used. In general, the more examples you have, the more reliable the response will be, but it will increase latency and consume tokens. to make the hint more readable, we only have one example here.
6. Detailed mission descriptions and rules Expand on the specific tasks you want Claude to perform and any rules Claude may need to follow. If Claude doesn't have an answer or doesn't know, an "exit" option is also available here. "Write a clear and concise answer to this question: the {{QUESTION}} answer should be no more than a few paragraphs long. If possible, it should end with a single sentence that directly answers the user's question. However, if there is not enough information in the compiled research to produce such an answer, you can write 'I'm sorry, I don't have enough information at hand to answer this question.'" It is a good idea to show this description and the rules to a friend to ensure that the layout is logically clear and any ambiguous terms are clearly explained.
7. Immediate mission description or request "Remind" Claude or tell Claude about tasks that need to be performed immediately. This is also where additional variables such as user questions are placed. To reiterate Claude Immediate tasks are usually not harmful and are best placed at the end of longer prompts. This produces better results than placing it at the beginning. It is also usually better to place the user query near the bottom of the prompt.
8. Pre-reflection (step-by-step) (optional) For multi-step tasks, it's a good idea to tell Claude to think step-by-step before giving an answer. Sometimes you may even need to say "Before you give the answer..." to make sure Claude does this first. Before you answer, extract the most relevant quotes from your research and enclose them in tags. This increases the intelligence of the response, but also increases the latency by increasing the length of the output. In this example, the anticipation step is embedded in the "Detailed Task Description and Rules" section, which asks Claude to identify key points of law.
9. Output format (optional) If there is a specific format required, clearly tell Claude what that format is. Place your two-paragraph response in the tabs. Depending on the task, this element may not be necessary.
10. Pre-populated Claude's response (if any) Start Claude's answer with some pre-populated text to guide Claude's behavior or response. If you want to pre-populate Claude's response, you must include "Assistant:" and it must be on a new line or it will be treated as part of the "User:" round (we'll do this step for you automatically in this exercise). Assistant: "Assistant:" is only necessary if you want to pre-populate Claude's answer. Otherwise, it can be omitted.

Now let's link everything together, make the substitutions, and see the effect!

Tip: If you want to see the full cue box, you can copy and paste the yellow replacement cue box into a text editor.

Cue template (spliced from above)

用户:你是一位专业的律师。  

这里有一些已经整理好的研究资料。利用这些资料回答用户的法律问题。  
<legal_research>  
{{LEGAL_RESEARCH}}  
</legal_research>  

在回答中引用法律研究时,请使用包含搜索索引 ID 的方括号,后面跟一个句点。将这些放在引用句子的末尾。正确引用格式的示例:  

<examples>  
<example>  
这种罪行的诉讼时效为 10 年。[3]。  
</example>  
<example>  
然而,当双方明确放弃保护时,该保护不适用。[5]。  
</example>  
</examples>  

用简明扼要的方式回答以下问题:  

<question>  
{{QUESTION}}  
</question>  

回答应不超过几段。如果可能,应该以直接回答用户问题的单句结尾。然而,如果编纂的研究中没有足够的信息来生成这样的答案,你可以回绝并写“对不起,我手头没有足够的信息来回答这个问题。”  

在回答之前,从研究资料中提取出最相关的引用,放在 <relevant_quotes> 标签中。  

将你的两段回复放在 <answer> 标签中。  
助手: <relevant_quotes>

variant

Input {{QUESTION}}

在飓风期间,关于如何处理宠物的法律规定有哪些?

Input {{LEGAL_RESEARCH}}

<search_results>  
<search_result id=1>  
在过去一年中,动物健康行业卷入了多个专利和商标诉讼案件。1994 年,Barclay Slocum 获得了胫骨平台水平截骨术的专利,该手术用于治疗狗的前交叉韧带断裂,以及用于该手术的设备。2006 年,Slocum Enterprises 对 New Generation Devices 提起了专利侵权诉讼,争辩称 New Generation 生产的 Unity Cruciate Plate 侵犯了 Slocum TPLO 板的专利。然而,法院未就专利侵权问题作出裁决,裁定由于案件所在州销售的板材数量较少及 Slocum Enterprises 维护的一个网站上的信息,法院没有管辖权。其他在 2006 年进行的专利争夺战涉及了激光技术在猫的爪子切除术中的应用、宠物识别芯片、猪疫苗和宠物“去毛”工具。  
</search_result>  
<search_result id=2>  
在加拿大,不列颠哥伦比亚省兽医医学协会对一名非兽医提起了诉讼,声称该非兽医从事了切割或以其他方式去除马牙上的钩子以及使用电动和手动工具对马牙进行打磨,收取费用提供建议和诊断,并声称自己有资格提供这些活动相关的治疗。法院认为,立法机关通过《兽医职业法》的意图是保护公众和动物,并进一步认为垄断性法规的目的是保护公众。此外,法院还得出结论,牙科本质上与牙齿和牙龈的健康有关;与动物的美容和其他类型的护理不同;因此,属于兽医医学实践的定义范围。该非兽医被禁止在没有兽医监督的情况下提供服务。  
</search_result>  
<search_result id=3>  
2005 年袭击美国 Gulf Coast 的卡特里娜飓风之后,引发了对自然灾害中动物处理方式的改变。2006 年,夏威夷、路易斯安那州和新罕布什尔州都制定了法律,解决了灾难期间动物护理的问题,例如为宠物提供避难所,并允许服务动物与其服务的人员一起待在一起。此外,国会在 2006 年通过了《宠物撤离和运输标准法》,总统签署了该法案,要求州和地方应急准备部门在撤离计划中包括如何在灾难发生时安置家庭宠物和服务动物的信息。加利福尼亚州通过了一项法律,要求其应急服务办公室、农业部以及其他参与灾难响应准备的机构制定一个计划,以满足灾难或重大紧急情况下服务动物、家畜、马类和家庭宠物的需求。  
</search_result>  
</search_results>

Splicing cue words with substitution

用户:你是一位专业律师。

这里有一些已经整理好的研究资料。请它来回答用户的法律问题。
<legal_research>
<search_results>
<search_result id=1>
在过去一年中,动物健康行业卷入了一系列专利和商标诉讼。1994年,Barclay Slocum获得了胫骨平台水平截骨术(用于治疗犬前十字韧带断裂)的专利,以及用于该手术的器械专利。2006年,Slocum Enterprises对New Generation Devices提起专利侵权诉讼,声称New Generation生产的Unity Cruciate Plate侵犯了Slocum TPLO板的专利。然而,法院并未就专利侵权问题做出裁决,而是基于在提起诉讼的州内销售的板数量很少,以及Slocum Enterprises网站提供的信息,裁定法院对此案没有管辖权。2006年发生的其他专利争端涉及激光技术在猫爪切除术中的应用、宠物识别芯片、猪疫苗和宠物"去毛"工具。
</search_result>
<search_result id=2>
在加拿大,不列颠哥伦比亚兽医协会起诉了一名非兽医,指控他从事切割或以其他方式去除马牙钩和用电动及手动工具磨平马牙,收费提供建议和诊断,并自称有资格并愿意提供这些活动相关的治疗。法院认为立法机关制定《业法》的意图是保护公众和动物,并进一步认为垄断性法规serve the purpose of protecting the public。此外,法院牙科的核心是关于牙齿和牙龈的健康;与动物的美容和其他类型的护理不同;因此,属于兽医执业的定义范围。法院禁止该非兽医在没有兽医监督的情况下提供服务。
</search_result>
<search_result id=3>
2005年袭击美国墨西哥湾沿岸的卡特里娜飓风的余波,促使人们改变了在自然灾害期间对待动物的方式。2006年,夏威夷、路易斯安罕布什尔州都颁布了法律,解决了灾害期间动物照料的问题,如为宠物提供庇护所,允许服务动物与其服务的人在一起。此外,2006年国会通过并由总统签署了《宠物疏散和运输准法案》,该法案要求州和地方应急准备部门在其疏散计划何在发生灾害时安置家庭宠物和服务动物的信息。加利福尼亚州通过了一项法律,要求其应急服务办公室、农业部和其他参与灾害应对准备的机构制定一项计划,以应对发生灾害或重大紧急情况时服务动物、牲畜、马科动物和家庭宠物的需求。
</search_result>
</search_results>
</legal_research>

在的回答中引用法律研究时,请使用包含搜索索引ID的方括号,后跟一个句点。将这些放在引用的句子末尾。以下是正确引用格式的例子:

<examples>
<example>
这类犯罪的诉讼时效期限为10年。[3]。
</example>
<example>
然而,当双方明确放弃保护时,该保护不适用。[5]。
</example>
</examples>

请对这个问题给出一个清晰、简洁的回答:

<question>
有关飓风期间如何处理宠物的法律吗?
</question>

回答不应超过两。如果可能,应以一句话直接回答用户的问题作为结是,如果所提供的研究资料中没有足够的信息来产生这样的回答,你可以婉拒并写道"抱歉,我手头没有足够的信息来回答这个问题。"。

在回答之前,请在<relevant_quotes>标签中列出研究资料中最相关的引用。

请将你的两段回答放在<answer>标签中。
Assistant: <relevant_quotes>

Claude's answer

"2006年,夏威夷、路易斯安那州和新罕布什尔州都颁布了法律,解决灾害期间动物照护问题,如为宠物提供庇护所,并允许服务动物与其服务的人在一起。此外,2006年国会通过并由总统签署了《宠物疏散和运输标准法案》,该法案要求州和地方应急准备部门在其疏散计划中包括如何在灾害发生时安置家庭宠动物的信息。" [3]
"加利福尼亚州通过了一项法律,要求其应急服务办公室、农业部和其他参与灾害应对准备的机构制定计划,以应对灾害或重大紧急情况下服务动物、牲畜、马科动物和家庭宠物的需求。" [3]
</relevant_quotes>

<answer>
研究表明,关于飓自然灾害期间宠物处题,已经有几项法律出台。2006年,包括夏威夷、路易斯安那州和新罕布什尔州在内的几个州制定了法律,要求庇护所接纳宠物,并允许服务动物在疏散期间与主人待在一起。 此外,联邦政府在2006年通过了《宠物疏散和运输标准法案》,该法案要求州和地方应急准备部门在其灾害应对计划中包括安置家庭宠物和服务动物的计划。 [3] 加利福尼亚州还通过了一项法律,要求州政府机构制定计划,以解决紧急情况下宠物、牲畜和其他动物的需3]

总之,现在已经有各种法律要求应急部门在飓风等自然灾害期间为宠物的照护和疏散做出规定。
</answer>
May not be reproduced without permission:Chief AI Sharing Circle " Anthropic Prompts Engineering Course - Chapter 9: Complex Prompts for Legal Services
en_USEnglish