Prompt示例

Prompt技巧

观点

明确的提示:

a、用特殊符号进行明确的划分「指令」「处理内容」「三个点」「####」;

b、明确模型的输出格式「以 json 的形式返回,json 中应当包含以下三个 key: 书籍名称,书籍作者,售价。」;

c、设定检测条件「设定一些条件,当句子满足我们的条件时我们才让模型输出我们想要的内容」;

d、提供一些示例;

e、思维链「执行以下操作、每一个操作的答案单独输出为一行、使用下面的格式输出每一步的结果」;

f、根据意外迭代prompt

实战经验:

a、面向对象、面向对象的哪个方面的事情「你的任务是为xx做xx事情」

b、「你只需要回答,"正向情感"或是"负向情感"」

c、「将你的答案格式化为用逗号分隔的列表形式」

看法:

a. 关键词:结合业务、直接、简单、清晰。

b. 以下面的示例说明:

‒ 用###进行块划分、说明每个部分的内容

‒ 给出示例

‒ 明确定义输出格式

‒ 明确给出要求,实际业务当中会涉及更多的要求「不同意图、不同类型POI等等」

参考资料

26个准则

如何写好prompt

自动文案

上下文记忆压缩之对话总结

langchain.memory.summary.ConversationSummaryMemory

Prompt作用:逐步总结所提供的对话内容,添加到先前的摘要中,返回新的摘要

要点总结:

(1)用空行来划分

(2)类似kv的表述:Current summary、New lines of conversation、New summary

(3)关键词:EXAMPLE、END OF EXAMPLE

python 复制代码
Progressively summarize the lines of conversation provided, adding onto the previous summary returning a new summary.

EXAMPLE
Current summary:
The human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good.

New lines of conversation:
Human: Why do you think artificial intelligence is a force for good?
AI: Because artificial intelligence will help humans reach their full potential.

New summary:
The human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good because it will help humans reach their full potential.
END OF EXAMPLE

Current summary:
{summary}

New lines of conversation:
{new_lines}

New summary:

ReAct模式的Agent prompt

zero-shot-react-description

用LLM来规划使用工具,以解决问题

python 复制代码
{
  "load_from_llm_and_tools": true,
  "_type": "zero-shot-react-description",
  "prefix": "Answer the following questions as best you can. You have access to the following tools:",
  "suffix": "Begin!\n\nQuestion: {input}\nThought:{agent_scratchpad}"
}

zero-shot-react-sql

python 复制代码
Answer the question as best you can.
 The answer you return should come directly from the database tools. Be very explicit and specific with what you want when you ask the databases for information. Finally, don't use SQL syntax in your request but rather use natural language. If you cannot get an answer from the provided tools, say "There is not enough information in the DB to answer the question."
You have access to the following DB:

prefix的翻译内容:

尽你所能回答这个问题。

你返回的答案应该直接来自数据库工具。当你向数据库请求信息时,要非常明确和具体。最后,不要在你的请求中使用SQL语法,而是使用自然语言。如果你无法从提供的工具中获得答案,请说"数据库中的信息不足以回答这个问题。"

你可以访问以下数据库:

其他prompt的template

QA的map阶段

python 复制代码
Use the following portion of a long document to see if any of the text is relevant to answer the question. 
Return any relevant text verbatim.
{context}
Question: {question}
Relevant text, if any:

翻译内容:

使用以下长文档的一部分来检查文本中是否有任何内容与回答问题相关。

如有相关文本,原样返回。

{context}

问题: {question}

如果有相关的文本,请提供:

QA的reduce阶段

python 复制代码
Given the following extracted parts of a long document and a question, create a final answer. 
If you don't know the answer, just say that you don't know. Don't try to make up an answer.

QUESTION: Which state/country's law governs the interpretation of the contract?
=========
Content: This Agreement is governed by English law and the parties submit to the exclusive jurisdiction of the English courts in  relation to any dispute (contractual or non-contractual) concerning this Agreement save that either party may apply to any court for an  injunction or other relief to protect its Intellectual Property Rights.

Content: No Waiver. Failure or delay in exercising any right or remedy under this Agreement shall not constitute a waiver of such (or any other)  right or remedy.

11.7 Severability. The invalidity, illegality or unenforceability of any term (or part of a term) of this Agreement shall not affect the continuation  in force of the remainder of the term (if any) and this Agreement.

11.8 No Agency. Except as expressly stated otherwise, nothing in this Agreement shall create an agency, partnership or joint venture of any  kind between the parties.

11.9 No Third-Party Beneficiaries.

Content: (b) if Google believes, in good faith, that the Distributor has violated or caused Google to violate any Anti-Bribery Laws (as  defined in Clause 8.5) or that such a violation is reasonably likely to occur,
=========
FINAL ANSWER: This Agreement is governed by English law.

QUESTION: What did the president say about Michael Jackson?
=========
Content: Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans.  

Last year COVID-19 kept us apart. This year we are finally together again. 

Tonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. 

With a duty to one another to the American people to the Constitution. 

And with an unwavering resolve that freedom will always triumph over tyranny. 

Six days ago, Russia's Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. 

He thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. 

He met the Ukrainian people. 

From President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world. 

Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland.

Content: And we won't stop. 

We have lost so much to COVID-19. Time with one another. And worst of all, so much loss of life. 

Let's use this moment to reset. Let's stop looking at COVID-19 as a partisan dividing line and see it for what it is: A God-awful disease.  

Let's stop seeing each other as enemies, and start seeing each other for who we really are: Fellow Americans.  

We can't change how divided we've been. But we can change how we move forward---on COVID-19 and other issues we must face together. 

I recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera. 

They were responding to a 9-1-1 call when a man shot and killed them with a stolen gun. 

Officer Mora was 27 years old. 

Officer Rivera was 22. 

Both Dominican Americans who'd grown up on the same streets they later chose to patrol as police officers. 

I spoke with their families and told them that we are forever in debt for their sacrifice, and we will carry on their mission to restore the trust and safety every community deserves.

Content: And a proud Ukrainian people, who have known 30 years  of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards.  

To all Americans, I will be honest with you, as I've always promised. A Russian dictator, invading a foreign country, has costs around the world. 

And I'm taking robust action to make sure the pain of our sanctions  is targeted at Russia's economy. And I will use every tool at our disposal to protect American businesses and consumers. 

Tonight, I can announce that the United States has worked with 30 other countries to release 60 Million barrels of oil from reserves around the world.  

America will lead that effort, releasing 30 Million barrels from our own Strategic Petroleum Reserve. And we stand ready to do more if necessary, unified with our allies.  

These steps will help blunt gas prices here at home. And I know the news about what's happening can seem alarming. 

But I want you to know that we are going to be okay.

Content: More support for patients and families. 

To get there, I call on Congress to fund ARPA-H, the Advanced Research Projects Agency for Health. 

It's based on DARPA---the Defense Department project that led to the Internet, GPS, and so much more.  

ARPA-H will have a singular purpose---to drive breakthroughs in cancer, Alzheimer's, diabetes, and more. 

A unity agenda for the nation. 

We can do this. 

My fellow Americans---tonight , we have gathered in a sacred space---the citadel of our democracy. 

In this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. 

We have fought for freedom, expanded liberty, defeated totalitarianism and terror. 

And built the strongest, freest, and most prosperous nation the world has ever known. 

Now is the hour. 

Our moment of responsibility. 

Our test of resolve and conscience, of history itself. 

It is in this moment that our character is formed. Our purpose is found. Our future is forged. 

Well I know this nation.
=========
FINAL ANSWER: The president did not mention Michael Jackson.

QUESTION: {question}
=========
{summaries}
=========
FINAL ANSWER:
相关推荐
林泽毅3 小时前
PaddleNLP框架训练模型:使用SwanLab教程
人工智能·深度学习·机器学习·大模型·paddlepaddle·模型训练·swanlab
AI大模型顾潇4 小时前
[特殊字符] 本地大模型编程实战(29):用大语言模型LLM查询图数据库NEO4J(2)
前端·数据库·人工智能·语言模型·自然语言处理·prompt·neo4j
程序边界4 小时前
AIGC时代 | 终端设备上的大模型轻量化部署:模型压缩与量化全栈方案
大模型
java干货7 小时前
每日Prompt:三只动物与地标自拍
prompt
0x2117 小时前
[论文阅读]Formalizing and Benchmarking Prompt Injection Attacks and Defenses
论文阅读·prompt
水煮蛋不加蛋7 小时前
RAG 赋能客服机器人:多轮对话与精准回复
人工智能·ai·机器人·大模型·llm·rag
wei_shuo8 小时前
深度剖析 GpuGeek 实例:GpuGeek/Qwen3-32B 模型 API 调用实践与性能测试洞察
大模型·gpu算力·gpuseek
倔强的石头1069 小时前
大模型微调实战:基于GpuGeek平台的低成本高效训练方案
ai·大模型·gpu
Panesle17 小时前
分布式异步强化学习框架训练32B大模型:INTELLECT-2
人工智能·分布式·深度学习·算法·大模型
java干货17 小时前
每日Prompt:定制动漫手办
prompt