From 0d2a7047a504a0d3a6bf5e02c6a1898c347c8b97 Mon Sep 17 00:00:00 2001 From: afondiel Date: Thu, 13 Jun 2024 11:55:05 +0200 Subject: [PATCH] ai-prompt-eng: add notes --- .../prompt-engineering-notes.md | 122 ++++++++++++++++++ ai/prompt-engineering-notes/readme.md | 23 +--- 2 files changed, 125 insertions(+), 20 deletions(-) create mode 100644 ai/prompt-engineering-notes/prompt-engineering-notes.md diff --git a/ai/prompt-engineering-notes/prompt-engineering-notes.md b/ai/prompt-engineering-notes/prompt-engineering-notes.md new file mode 100644 index 0000000..5ed8579 --- /dev/null +++ b/ai/prompt-engineering-notes/prompt-engineering-notes.md @@ -0,0 +1,122 @@ +# Prompt Engineering - Notes + +## Table of Contents (ToC) + + - [Introduction](#introduction) + - [What's Prompt Engineering?](#whats-prompt-engineering) + - [Key Concepts and Terminology](#key-concepts-and-terminology) + - [Applications](#applications) + - [Fundamentals](#fundamentals) + - [Prompt Engineering Architecture Pipeline](#prompt-engineering-architecture-pipeline) + - [How Prompt Engineering Works?](#how-prompt-engineering-works) + - [Prompt Engineering Techniques](#prompt-engineering-techniques) + - [Some Hands-on Examples](#some-hands-on-examples) + - [Tools \& Frameworks](#tools--frameworks) + - [Hello World!](#hello-world) + - [Lab: Zero to Hero Projects](#lab-zero-to-hero-projects) + - [References](#references) + - [References](#references-1) + + +## Introduction +Prompt engineering is the process of designing and optimizing prompts for AI models to elicit the desired responses. + +### What's Prompt Engineering? +- Crafting input prompts to guide AI outputs. +- Enhancing model performance with well-designed prompts. +- A critical skill for interacting with AI systems effectively. + +### Key Concepts and Terminology +- **Prompt**: The input given to an AI model. +- **Completion**: The output generated by the AI model. +- **Tokens**: Units of text the model processes. +- **Context**: The surrounding text influencing the model's output. + +### Applications +- Generating human-like text in chatbots. +- Summarizing documents and articles. +- Automating customer service responses. +- Creating interactive AI-based tools. + +## Fundamentals + +### Prompt Engineering Architecture Pipeline +- Defining the task and objectives. +- Crafting initial prompts. +- Iterative testing and refinement. +- Evaluating model outputs for desired performance. + +### How Prompt Engineering Works? +- Identifying the purpose and scope of the task. +- Designing prompts with specific instructions. +- Utilizing examples to guide model responses. +- Refining prompts based on model feedback. + +### Prompt Engineering Techniques +- **Zero-shot**: Providing no examples, relying on the model's general knowledge. +- **Few-shot**: Giving a few examples to guide the model. +- **One-shot**: Providing a single example to demonstrate the task. +- **Multi-shot**: Offering multiple examples to improve response accuracy. +- **Chain-of-thought**: Structuring prompts to show the reasoning process step-by-step. + +### Some Hands-on Examples +- **Text Summarization**: Crafting prompts for concise summaries. +- **Conversational Agents**: Designing prompts for engaging dialogues. +- **Content Generation**: Creating prompts for writing assistance. + +## Tools & Frameworks +- OpenAI GPT +- Hugging Face Transformers +- Google's T5 +- Microsoft DialoGPT + +## Hello World! +```python +import openai + +# Set up the OpenAI API key +openai.api_key = 'your-api-key' + +# Define a simple prompt +prompt = "Explain the concept of prompt engineering in AI." + +# Get the completion from the AI model +response = openai.Completion.create( + engine="text-davinci-003", + prompt=prompt, + max_tokens=100 +) + +# Print the response +print(response.choices[0].text.strip()) +``` + +## Lab: Zero to Hero Projects +- **Project 1**: Building a FAQ chatbot using prompt engineering. +- **Project 2**: Creating a personalized email assistant. +- **Project 3**: Developing a story generator with adjustable prompts. +- **Project 4**: Designing an AI-driven content summarizer. + +## References +- [OpenAI documentation](https://beta.openai.com/docs/) +- [Hugging Face Transformers](https://huggingface.co/transformers/) +- [Google's T5](https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html) +- [Microsoft DialoGPT](https://github.com/microsoft/DialoGPT) +- https://www.promptingguide.ai/techniques + +Free Course: + +- [Course on ChatGPT Prompt Engineering for Developers - by DeepLearningAI](https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/2/guidelines) + +Awesome ChatGPT Prompts: + +- [Awesome ChatGPT Prompts](https://prompts.chat/) +- [Awesome GPT Prompts](https://www.awesomegptprompts.com/) + +Visual Prompting + +- [INTRODUCING - Visual Prompting - @LandingAI](https://landing.ai/) +- [What is Visual Prompting? - LandingAI](https://landing.ai/blog/what-is-visual-prompting/) +- [Visual Prompting Livestream With Andrew Ng](https://www.youtube.com/watch?v=FE88OOUBonQ) +- [CVPR 2023 Tutorial on Prompting in Vision](https://prompting-in-vision.github.io/) + diff --git a/ai/prompt-engineering-notes/readme.md b/ai/prompt-engineering-notes/readme.md index e49b48e..68319a2 100644 --- a/ai/prompt-engineering-notes/readme.md +++ b/ai/prompt-engineering-notes/readme.md @@ -7,25 +7,8 @@ Credits to : Max Rascher +## Contributing +Please refer to this [CONTRIBUTING.md](../../CONTRIBUTING.md) file. -## References - -Free Course : - -- [Course on ChatGPT Prompt Engineering for Developers - by DeepLearningAI](https://learn.deeplearning.ai/chatgpt-prompt-eng/lesson/2/guidelines) - -Awesome ChatGPT Prompts : - -- [Awesome ChatGPT Prompts](https://prompts.chat/) -- [Awesome GPT Prompts](https://www.awesomegptprompts.com/) - -Visual Prompting - -- [INTRODUCING - Visual Prompting - @LandingAI](https://landing.ai/) -- [What is Visual Prompting? - LandingAI](https://landing.ai/blog/what-is-visual-prompting/) -- [Visual Prompting Livestream With Andrew Ng](https://www.youtube.com/watch?v=FE88OOUBonQ) -- [CVPR 2023 Tutorial on Prompting in Vision](https://prompting-in-vision.github.io/) - - - +> **"...And so my hope is someday when the next Aristotle is alive, we can capture the underlying worldview of that Aristotle, in a computer, and someday some students will be able to not only read the words Aristotle wrote but ask Aristotle a question and get an answer."** - Steve Jobs (Generative AI Prediction from 1985 Speech) \ No newline at end of file