diff --git a/_posts/2024-08-15-Prompt-Engineering.md b/_posts/2024-08-15-Prompt-Engineering.md new file mode 100644 index 00000000..57066619 --- /dev/null +++ b/_posts/2024-08-15-Prompt-Engineering.md @@ -0,0 +1,138 @@ +--- +layout: post +title: Prompt Engineering +author: [Richard Kuo] +category: [Lecture] +tags: [jekyll, ai] +--- + +Prompt Engineering (提示工程), Chain-of-Thought Prompting + +--- +## 初級入門(免費課程) +* [Prompt Engineering with Llama 2](https://www.deeplearning.ai/short-courses/prompt-engineering-with-llama-2/)
+* [Deep Learning Generative AI short courses](https://www.deeplearning.ai/short-courses/)
+![](https://github.com/rkuo2000/AI-course/blob/main/images/Prompting-101.jpg?raw=true) + +### [Prompt Engineering](https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/)
+aka **In-Context Prompting**
+* Basic Prompting + - Zero-shot + - Few-shot +* Instruction Prompting +* Self-Consistency Sampling +* Chain-of-Thought (CoT) +* Automatic Prompt Design +* [Augmented Language Models](https://arxiv.org/abs/2302.07842) +![](https://github.com/rkuo2000/AI-course/blob/main/images/LLM_prompt_patterns.jpg?raw=true) + +**Blog:** [LLM 各種技巧 | Prompt Engineering 大總結 | 指南](https://medium.com/@cch.chichieh/llm-%E5%90%84%E7%A8%AE%E6%8A%80%E5%B7%A7-prompt-engineering-%E6%8C%87%E5%8D%97-6ac4201a4cbe)
+ +--- +## 生成式AI導論 + +### 【生成式AI導論 2024】第3講:訓練不了人工智慧?你可以訓練你自己 (上) — 神奇咒語與提供更多資訊 + + +--- +### 【生成式AI導論 2024】第4講:訓練不了人工智慧?你可以訓練你自己 (中) — 拆解問題與使用工具 + + +--- +### 【生成式AI導論 2024】第5講:訓練不了人工智慧?你可以訓練你自己 (下) — 讓語言彼此合作,把一個人活成一個團隊 + + +--- +## 神奇的咒語 +不是對所有的模型都有用
+![](https://github.com/rkuo2000/AI-course/blob/main/images/prompt_principles_for_instructions.jpg?raw=true) +![](https://github.com/rkuo2000/AI-course/blob/main/images/chatgpt_cheat_sheet_v2.jpg?raw=true) + +### 1. 要語言模型思考: "Think about it Step-by-Step" +**Paper:** [Chain-of-Thought Prompting Elicits Reasoning in Large Language Models](https://arxiv.org/abs/2201.11903)
+![](https://ar5iv.labs.arxiv.org/html/2201.11903/assets/x1.png) + +--- +### 2. 要語言模型解釋: "Explain it" +**Paper:** [Can Large Language Models Be an Alternative to Human Evaluation?](https://arxiv.org/abs/2305.01937)
+![](https://aisholar.s3.ap-northeast-1.amazonaws.com/posts/July2023/Can_Large_Language_Models_Be_an_Alternative_to_Human_Evaluation_fig1.png) + +--- +### 3. 對語言模型情緒勒索: "This is very important to my career" +**Paper:** [Large Language Models Understand and Can be Enhanced by Emotional Stimuli](https://arxiv.org/abs/2307.11760)
+![](https://digitalrosh.com/wp-content/uploads/2024/01/EmotionPrompt.jpg) + +--- +### 4. 對語言模型下原則性指導 (Principled Instructions) +**Paper:** [Principled Instructions Are All You Need for Questioning LLaMA-1/2, GPT-3.5/4](https://arxiv.org/abs/2312.16171)
+![](https://arxiv.org/html/2312.16171v2/x1.png) +1. 對它說話不用客氣, 對它有什麼要求直說無妨 +2. 給它明確的指示, 直說要它做甚麼, 不用跟它說不做什麼 +3. 跟它說如果做得好,會給它小費$xxx +4. 跟它說做不好, 它會得到處罰 +5. 跟它說要保證它的答案是沒有偏見的, 而且要避免使用任何刻板印象 +... + +--- +### 5.直接問語言模型給更強大的咒語 (Forward Generation Template) +* `Let's think step by step` +* `Take a deep breath then work on this problem step by step` + +--- +### 6. 輸入額外範例 +**In-Context Learning**
+ +**Paper:** [Language Models are Few-Shot Learners](https://arxiv.org/abs/2005.14165)
+![](https://miro.medium.com/v2/resize:fit:720/format:webp/1*1PJi06R7QMTGBh8CdIsW8w.png) + +--- +### 7. 拆解任務 (Recursive Reprompting and Revision) +**Paper:** [Re3: Generating Longer Stories With Recursive Reprompting and Revision](https://arxiv.org/abs/2210.06774)
+**Paper:** [Joint Prompt Optimization of Stacked LLMs using Variational Inference](https://arxiv.org/abs/2306.12509)
+ +--- +### 8. 要語言模型去使用工具 +**Paper:** [AnyTool: Self-Reflective, Hierarchical Agents for Large-Scale API Calls](https://arxiv.org/abs/2402.04253)
+![](https://github.com/rkuo2000/AI-course/blob/main/images/Prompting_AnyTool.png?raw=true) + +--- + +--- +### 9. 自動提示比手工編寫的提示好 +**Paper:** [The Unreasonable Effectiveness of Eccentric Automatic Prompts](https://arxiv.org/html/2402.10949v2)
+**Blog:** [要求AI模仿《星際爭霸戰》能提升效能,但還是用「自動優化」以魔法打敗魔法最有效 +](https://www.techbang.com/posts/113796-asking-the-ai-to-answer-in-the-way-of-a-starcraft-character)
+ +--- +### 10. 要語言模型摘要文章/論文後寫出簡報/文章 +**收集, 啟發, 輸出**
+* 一段一段分析文章中提供了什麼解決方法 +* 如何解決我提出的需求與問題? +* 根據問題, 詳列摘要重點 +* 改寫成精簡但精采的簡報大綱 + +**Paper:** [Constitutional AI: Harmlessness from AI Feedback](https://arxiv.org/abs/2212.08073)
+ +--- +## Chain-of-Thought Prompting +**Blog:** [How to Make ChatGPT Smarter: Chain of Thought Prompting](https://medium.com/@wadan/how-to-make-chatgpt-smarter-chain-of-thought-prompting-bd796efa1e03)
+ +### [Chain-of-Thought Prompting](https://www.promptingguide.ai/techniques/cot) +![](https://www.promptingguide.ai/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fcot.1933d9fe.png&w=1080&q=75) + +1. **Zero-shot COT Prompting** +![](https://www.promptingguide.ai/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fzero-cot.79793bee.png&w=1080&q=75) + +2. **Automatic Chain-of-Thought (Auto-CoT)** +![](https://www.promptingguide.ai/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fauto-cot.642d9bad.png&w=1200&q=75) + +--- +### [Chain of thought and ReAct — SQL Agent](https://abvijaykumar.medium.com/prompt-engineering-chain-of-thought-and-react-sql-agent-85fa42575c06) +![](https://miro.medium.com/v2/resize:fit:720/format:webp/1*XBh0aKnnFvI5wvpi5LAv4A.png) + + +
+
+ +*This site was last updated {{ site.time | date: "%B %d, %Y" }}.* +