Prompt Engineering Tutorial Using Generative AI (ChatGPT) with DataScience
เนื้อหาประมาณ 3 ชั่วโมงอาจะมีช่วยเร่งหรือข้ามเพื่อให้ทันเวลา
- Master the Art of Prompt Engineering for Effective AI Solutions

นำเสนอโดย
ฉัตรชัย หลิมประเสริฐศิริ บริษัทเน็กเวฟเวอร์ดอตเนทจำกัด
ประสบการณ์ 30ปี ด้าน DW,BI,ML,DL,AI ทำงานให้ทั้งภาครัฐและเอกชน
Admin :Thailand Deep Learning Group
วันที่ 18 มีนาคม 2023

Agenda
- Introduction to Prompt Engineering (30 minutes)
- Key Concepts in Prompt Engineering (60 minutes)
- Practical Practice with Prompt Engineering (90 minutes)
- Advanced Techniques in Prompt Engineering (30 minutes)
- Summary and Future Directions (30 minutes)
เครื่องมือที่ใช้
OpenAI API/PlayGroud https://platform.openai.com/examples
GraphGPT
ChatGPT https://chat.openai.com
Bing Chat Bing
Midjourney/DallE/Stability Diffusion https://discord.com/,https://www.midjourney.com/app/
PlantUML/GraphvizOnline http://www.plantuml.com/plantuml/uml/
Youtube/SoundRecorder
Slides.com https://slides.com/chatchailimlim/deck-4f305e/fullscreen#/1/1
Excel/GoogleSheet
Google Doc/Google Translator /Google Earth
ChatPDF
Introduction to Prompt Engineering

Introduction to Prompt Engineering
-
Harnessing the Power of Generative AI for Data Science Applications
Agenda
-
Overview of Language Models and Their Implementation
-
Definition of Engineering Prompt and Its Importance
-
Examples of Successful Prompt Engineering Applications
Language Models
-
Definition of Language Models
-
Examples: GPT-3, BERT, Transformer, etc.
-
Applications: Text Generation, Sentiment Analysis, Machine Translation, etc.


Generative AI
-
Introduction to Generative AI
-
Generative vs. Discriminative Models
-
The Role of Generative AI in Data Science



Prompt Engineering
-
Definition of Prompt Engineering
-
The Importance of Engineering Prompts
-
The Role of Prompts in Language Models

Definition of Prompt Engineering
The Importance of Engineering Prompts
Prompt Engineering มีความสำคัญเนื่องจากจะเป็นตัวกำหนดคุณภาพของเอาต์พุตที่สร้างโดยโมเดล AI แนวคิดของ "ขยะเข้า ขยะออก" ใช้ได้ที่นี่: คุณภาพของอินพุตของคุณกำหนดคุณภาพของเอาต์พุตของคุณ
Prompt Engineering ได้กลายเป็นส่วนสำคัญของการประมวลผลภาษาธรรมชาติ (NLP) และมีบทบาทสำคัญในการปรับปรุงประสิทธิภาพของโมเดล AI ต่างๆ เมื่อเทคโนโลยีพัฒนาขึ้น วิศวกรรมที่รวดเร็วจะยังคงมีความสำคัญเพิ่มขึ้นและมีบทบาทสำคัญในการทำให้แน่ใจว่าระบบซอฟต์แวร์ต่างๆ สามารถสื่อสารได้อย่างมีประสิทธิภาพ

The Role of Prompts in Language Models
Engineering Prompts and Data Science
-
Effective Use of Prompts for Data Science Tasks
-
Ensuring Relevant and Accurate Model Outputs
-
Balancing Complexity and Efficiency

- เพื่อให้แน่ใจว่าเอาต์พุตของโมเดลมีความเกี่ยวข้องและแม่นยำ สิ่งสำคัญคือต้องใช้ชุดข้อมูลการฝึกอบรมขนาดใหญ่และแม่นยำ แบบจำลองสามารถมีความแม่นยำได้เท่ากับข้อมูลที่ใช้ในการสร้างเท่านั้น ดังนั้นข้อมูลที่มากขึ้นย่อมมีโอกาสแม่นยำสูง
- ข้อมูลที่ใช้ในแบบจำลองอาจไม่ถูกต้อง ไม่สมบูรณ์ หรือผิดเพี้ยน การพัฒนาแบบจำลองที่มีประสิทธิภาพเป็นสิ่งสำคัญ ดังนั้นข้อมูลที่มีข้อบกพร่องจึงมีศักยภาพที่จะประนีประนอมกับโมเดลทั้งหมด
- ตัวบ่งชี้ควรเกี่ยวข้องกับความต้องการของผู้ใช้และวัตถุประสงค์ของใช้งาน
รับรองการถามเพื่อให้ได้คำตอบ ที่เกี่ยวข้องและแม่นยำ

สร้างสมดุลระหว่างความซับซ้อนและประสิทธิภาพ ของการสร้างใช้งาน Prompt
Examples of Successful Engineering Applications
-
Example 1: Summarization of Scientific Articles
-
Example 2: Automated FAQ Generation
-
Example 3: Sentiment Analysis of Customer Reviews
Conclusion
-
Recap of Introduction to Prompt Engineering
-
Importance of Prompt Engineering in Data Science Applications
-
Transition to the Next Topic: Key Concepts in Prompt Engineering
Prompt Engineering Tutorial using Generative AI (ChatGPT) with Data Science Examples.
Example: Text Classification with GPT-3
Objective: Train GPT-3 to classify news articles into one of three categories: Technology, Business, or Health.
-
Understand the task: First, ensure you understand the task requirements and goals. In this case, the goal is to create a prompt that, when given a news article, will return the correct category.
-
Design a prompt: Create a clear and concise prompt that gives GPT-3 context and tells it what to do. For example, you could start with a prompt like this:
-
Test the prompt: Test the prompt with a few news article examples to see how well GPT-3 performs the task. You may need to adjust the prompt, add more context, or use a different approach based on the results.
-
Iterate and optimize: Based on the test results, refine your prompt for better performance. You may need to try several iterations to find the best prompt for this task. For example, you could make the prompt more explicit or provide examples within the prompt to guide GPT-3.
-
Evaluate performance: Once you have a refined prompt, evaluate its performance on a larger set of news articles. Assess the accuracy of the classification and identify areas for further improvement
Prompt
Input:http://bit.ly/3yMt98B
Please classify the following news article into one of the categories: Technology, Business, or Health.
Article title: [Article title]
Article content: [Article content]
The article belongs to the category:
Please classify the following news article into one of the categories: Technology, Business, or Health.
Article title: Bubble Trouble - Economist Says AI Is a Doomed Bubble Article content: The chatbot wars — led by ChatGPT creator OpenAI, Bing/Sydney overlord Microsoft, and the very desperate-to-catch-up Google — are on, with Silicon Valley behemoths and the industry's biggest investors rushing to throw major dollars behind language-generating systems. But according to a pair of experts in a scathing essay in Salon, the frothy hype cycle surrounding chatbot AIs is doomed to be what investors fear most: a bubble.
The article belongs to the category: Technology
Key Concepts in Prompt Engineering

Key Concepts in Prompt Engineering
- Designing Effective Prompts for Generative AI in Data Science Applications

Agenda
-
Understanding the Role of Prompts in Language Models
-
Effective Prompt Design Techniques
-
Best Practices for Optimizing Prompts
-
Understanding the Role of Prompts in Language Models
-
Effective Prompt Design Techniques
-
Best Practices for Optimizing Prompts
-
ทำความเข้าใจเกี่ยวกับบทบาทของพรอมต์ในรูปแบบโมเดลภาษา
-
เทคนิคการออกแบบพรอมต์ที่มีประสิทธิภาพ
-
แนวทางปฏิบัติที่ดีที่สุดสำหรับการเพิ่มประสิทธิภาพพรอมต์
Role of Prompts in Language Models
-
Definition of Prompts
-
How Prompts Guide Model Behavior
-
Importance of Prompts in Achieving Desired Outputs
-
ความหมายของพรอมต์
-
ลักษณะเฉพาะของโมเดลและการสื่อสารตามลักษณะเฉพาะ
-
ความสำคัญของการสื่อสารเพื่อการบรรลุผลลัพธ์ที่ต้องการ
Elements of Effective Prompt Design
-
Clarity: Clear and Concise Instructions
-
Context: Providing Relevant Information
-
Constraints: Defining Output Requirements
-
ความชัดเจน: คำแนะนำที่ชัดเจนและรัดกุม
-
บริบท: การให้ข้อมูลที่เกี่ยวข้อง
-
ข้อจำกัด: การกำหนดข้อกำหนดเอาต์พุต
Techniques for Prompt Design
-
Conversational Prompts
-
Multiple Choice Prompts
-
Incremental and Iterative Prompts
-
ข้อความแจ้งการสนทนา
-
พรอมต์หลายตัวเลือก
-
พร้อมท์ที่เพิ่มขึ้นและซ้ำ
Optimizing Prompts
-
Testing and Evaluating Model Outputs
-
Fine-tuning Parameters
-
Iterative Improvement Process
-
การทดสอบและประเมินผลของแบบจำลอง
-
พารามิเตอร์การปรับแต่งอย่างละเอียด
-
กระบวนการปรับปรุงซ้ำ
Best Practices for Prompt Engineering
-
Start Simple and Gradually Increase Complexity
-
Experiment with Different Prompt Styles
-
Monitor and Adjust Based on Model Performance
-
เริ่มต้นง่ายๆ แล้วค่อยๆ เพิ่มความซับซ้อน
-
ทดลองกับสไตล์พรอมต์ต่างๆ
-
ตรวจสอบและปรับตามประสิทธิภาพของโมเดล
Case Study: Content Summarization
-
Prompt Design Process
-
Evaluating and Optimizing the Prompt
-
Lessons Learned and Best Practices
-
ขั้นตอนการออกแบบพร้อมท์
-
การประเมินและเพิ่มประสิทธิภาพพรอมต์
-
บทเรียนที่ได้รับและแนวทางปฏิบัติที่ดีที่สุด
Conclusion
-
Recap of Key Concepts in Prompt Engineering
-
Importance of Effective Prompt Design in Data Science Applications
-
Transition to the Next Topic: Practical Practice with Prompt Engineering
-
สรุปแนวคิดหลักใน Prompt Engineering
-
ความสำคัญของการออกแบบพรอมต์ที่มีประสิทธิภาพแอปพลิเคชันด้านวิทยาศาสตร์ข้อมูล
-
การเปลี่ยนไปยังหัวข้อถัดไป: การปฏิบัติจริงกับพรอมต์ เอ็นจิเนียริ่ง
Practical Practice with Prompt Engineering
Hands-on Experience in Creating and Optimizing Prompts

Agenda
-
Tutorial Overview
-
Creating Prompts for Different Language Models
-
Group Discussions and Quick Feedback
Tutorial Overview
-
Objective: Gain hands-on experience in prompt engineering
-
Structure: Step-by-step instructions, examples, and group exercises
-
Outcome: Improved understanding and confidence in designing and optimizing prompts
-
วัตถุประสงค์: รับประสบการณ์จริง ที่รวดเร็ว
-
โครงสร้าง: คำแนะนำทีละขั้นตอน ตัวอย่าง และแบบฝึกหัดกลุ่ม
-
ผลลัพธ์: ปรับปรุงความเข้าใจและความมั่นใจในการออกแบบและปรับข้อความให้เหมาะสม
Creating Prompts for Different Language Models
-
GPT-3: OpenAI's Generative Pre-trained Transformer
-
BERT: Bidirectional Encoder Representations from Transformers
-
T5: Text-to-Text Transfer Transformer
-
GPT-3: Transformer Model ที่ได้รับการฝึกฝนมาล่วงหน้าของ OpenAI
-
BERT: การแทนตัวเข้ารหัสแบบสองทิศทางจาก Transformers
-
T5: ตัวแปลงการถ่ายโอนข้อความเป็นข้อความ
GPT-3 Prompt Example
-
Task: Summarize a given text
-
Prompt Design Process
-
Results and Optimization
-
งาน: สรุปข้อความที่กำหนด
-
ขั้นตอนการออกแบบพร้อมท์
-
ผลลัพธ์และการเพิ่มประสิทธิภาพ
BERT Prompt Example
-
Task: Sentiment Analysis
-
Prompt Design Process
-
Results and Optimization
-
งาน: การวิเคราะห์ความรู้สึก
-
ขั้นตอนการออกแบบพร้อมท์
-
ผลลัพธ์และการเพิ่มประสิทธิภาพ
T5 Prompt Example
-
Task: Translate text from one language to another
-
Prompt Design Process
-
Results and Optimization
-
งาน: แปลข้อความจากภาษาหนึ่งเป็นอีกภาษาหนึ่ง
-
ขั้นตอนการออกแบบพร้อมท์
-
ผลลัพธ์และการเพิ่มประสิทธิภาพ
Group Exercise Instructions
-
Divide into groups of 3-5 participants
-
Choose a language model and a task
-
Design a prompt and evaluate its performance
-
Share findings and optimization strategies with the group
-
แบ่งกลุ่ม กลุ่มละ 3-5 คน
-
เลือกรูปแบบภาษาและงาน
-
ออกแบบพรอมต์และประเมินประสิทธิภาพ
-
แบ่งปันสิ่งที่ค้นพบและกลยุทธ์การเพิ่มประสิทธิภาพกับกลุ่ม
Group Discussions and Quick Feedback
-
Share prompts created during the exercise
-
Discuss challenges, successes, and lessons learned
-
Provide feedback and suggestions for improvement
-
แบ่งปันคำแนะนำที่สร้างขึ้นระหว่างการออกกำลังกาย
-
หารือเกี่ยวกับความท้าทาย ความสำเร็จ และบทเรียนที่ได้รับ
-
ให้ข้อเสนอแนะและคำแนะนำในการปรับปรุง
Conclusion
-
Recap of Practical Practice with Prompt Engineering
-
Importance of Hands-on Experience in Mastering Prompt Engineering Skills
-
Transition to the Next Topic: Advanced Techniques in Prompt Engineering
-
สรุปภาคปฏิบัติกับพรอมท์ เอ็นจิเนียริ่ง
-
ความสำคัญของประสบการณ์จริงในการเรียนรู้ทักษะทางวิศวกรรม
-
การเปลี่ยนไปยังหัวข้อถัดไป: เทคนิคขั้นสูงใน Prompt Engineering
Advanced Techniques in Prompt Engineering
Harnessing the Power of Fine-Tuning and Transfer Learning
ใช้ประโยชน์จากพลังแห่งการปรับแต่งและถ่ายโอนการเรียนรู้ เพื่อการต่อยอดการเพิ่ม ประสบการณ์การใช้งาน
Harnessing the Power of Fine-Tuning and Transfer Learning

Agenda
-
Fine-Tuning in Language Models
-
Transfer Learning for Improved Performance
-
Case Studies of Successful Applications
-
การปรับแต่งโมเดลภาษาอย่างละเอียด
-
โอนการเรียนรู้เพื่อประสิทธิภาพที่ดีขึ้น
-
กรณีศึกษาของแอปพลิเคชันที่ประสบความสำเร็จ
Fine-Tuning in Language Models
-
Definition: Adapting pre-trained models to specific tasks or domains
-
Benefits: Improved accuracy, reduced training time, and better performance
-
Process: Start with pre-trained models, train on a smaller dataset, and adjust the model's weights
-
Definition: Adapting pre-trained models to specific tasks or domains
-
Benefits: Improved accuracy, reduced training time, and better performance
-
Process: Start with pre-trained models, train on a smaller dataset, and adjust the model's weights
-
คำนิยาม: การปรับแบบจำลองที่ได้รับการฝึกอบรมล่วงหน้าให้เหมาะกับงานหรือโดเมนเฉพาะ
-
ประโยชน์ที่ได้รับ: ความแม่นยำที่ได้รับการปรับปรุง เวลาการฝึกที่ลดลง และประสิทธิภาพที่ดีขึ้น
-
กระบวนการ: เริ่มต้นด้วยโมเดลที่ฝึกไว้ล่วงหน้า ฝึกชุดข้อมูลที่เล็กลง และปรับน้ำหนักของโมเดล
Transfer Learning for Improved Performance
-
Definition: Leveraging knowledge gained from one task to improve performance on another
-
Benefits: Accelerated learning, better generalization, and reduced training data requirements
-
Process: Use a pre-trained model as a starting point, fine-tune on the target task
-
คำนิยาม: การใช้ประโยชน์จากความรู้ที่ได้รับจากงานหนึ่งเพื่อปรับปรุงประสิทธิภาพงานอีกงานหนึ่ง
-
ประโยชน์ที่ได้รับ: การเรียนรู้ที่รวดเร็วขึ้น ภาพรวมที่ดีขึ้น และลดข้อกำหนดด้านข้อมูลการฝึกอบรม
-
กระบวนการ: ใช้โมเดลที่ฝึกไว้ล่วงหน้าเป็นจุดเริ่มต้น ปรับแต่งงานเป้าหมายอย่างละเอียด
Fine-Tuning Examples
-
GPT-3: Fine-tuning for domain-specific knowledge
-
BERT: Fine-tuning for sentiment analysis or entity recognition
-
T5: Fine-tuning for translation or summarization tasks
-
GPT-3: ปรับแต่งความรู้เฉพาะโดเมน
-
BERT: ปรับแต่งสำหรับการวิเคราะห์ความรู้สึกหรือการรับรู้เอนทิตี
-
T5: การปรับแต่งสำหรับงานแปลหรือการสรุป
Transfer Learning Examples
-
การเรียนรู้แบบ Zero-shot: การนำโมเดลไปใช้กับงานโดยไม่ต้องฝึกใหม่
-
การเรียนรู้เพียงไม่กี่ช็อต: การเรียนรู้ด้วยข้อมูลที่จำกัด
-
การเรียนรู้หลายงาน: แบบจำลองการฝึกอบรมเพื่อทำงานหลายอย่างพร้อมกัน
-
Zero-shot learning: Applying models to tasks without retraining
-
Few-shot learning: Learning with limited labeled data
-
Multi-task learning: Training models to perform multiple tasks simultaneously
Case Study 1
-
Company: XYZ
-
Problem: Custom sentiment analysis
-
Solution: Fine-tuned GPT model
-
Results: Improved accuracy and reduced training time
-
บริษัท: XYZ
-
ปัญหา: การวิเคราะห์ความรู้สึกที่กำหนดเอง
-
วิธีแก้ไข: โมเดล GPT-3 ที่ปรับแต่งอย่างละเอียด
-
ผลลัพธ์: ปรับปรุงความแม่นยำและลดเวลาการฝึก
Case Study 2
-
Company: ABC
-
Problem: Cross-lingual text classification
-
Solution: Transfer learning with GPT-3 model
-
Results: High performance across multiple languages
-
บริษัท : เอบีซี
-
ปัญหา: การจัดประเภทข้อความข้ามภาษา
-
วิธีแก้ไข: ถ่ายทอดการเรียนรู้ด้วยโมเดล GPT-3
-
ผลลัพธ์: ประสิทธิภาพสูงในหลายภาษา
Conclusion
-
Recap of Advanced Techniques in Prompt Engineering
-
Importance of Fine-Tuning and Transfer Learning for Efficient and Effective AI Solutions
-
Transition to the Final Topic: Summary and Future Directions
-
สรุปเทคนิคขั้นสูงใน Prompt Engineering
-
ความสำคัญของการปรับแต่งและถ่ายโอนการเรียนรู้เพื่อโซลูชัน AI ที่มีประสิทธิภาพและประสิทธิผล
-
การเปลี่ยนไปสู่หัวข้อสุดท้าย: บทสรุปและทิศทางในอนาคต
Tutorial Overview
-
Objective: Gain hands-on experience in prompt engineering
-
Structure: Step-by-step instructions, examples, and group exercises
-
Outcome: Improved understanding and confidence in designing and optimizing prompts
-
วัตถุประสงค์: รับประสบการณ์จริงในด้านวิศวกรรมที่รวดเร็ว
-
โครงสร้าง: คำแนะนำทีละขั้นตอน ตัวอย่าง และแบบฝึกหัดกลุ่ม
-
ผลลัพธ์: ปรับปรุงความเข้าใจและความมั่นใจในการออกแบบและปรับข้อความแจ้งให้เหมาะสม
BERT Prompt Example
-
https://huggingface.co/bert-base-uncased
-
Task: Sentiment Analysis
-
Prompt Design Process
-
Results and Optimization
T5 Prompt Example
-
https://huggingface.co/t5-base
-
Task: Translate text from one language to another
-
Prompt Design Process
-
Results and Optimization
Summary and Future Directions

Agenda
-
Recap of Main Topics Covered
-
Future Directions in Prompt Engineering R&D
-
Final Thoughts and Takeaways
-
สรุปหัวข้อหลักที่ครอบคลุม
-
ทิศทางในอนาคตของ Prompt Engineering R&D
-
ความคิดสุดท้ายและประเด็นสำคัญ
Recap of Main Topics Covered
-
Introduction to Prompt Engineering
-
Key Concepts in Prompt Engineering
-
Practical Practice with Prompt Engineering
-
Advanced Techniques in Prompt Engineering
-
ความรู้เบื้องต้นเกี่ยวกับ พรอมท์ เอ็นจิเนียริ่ง
-
แนวคิดหลักใน Prompt Engineering
-
ฝึกปฏิบัติจริงกับพรอมท์ เอ็นจิเนียริ่ง
-
เทคนิคขั้นสูงใน Prompt Engineering
Future Directions in Prompt Engineering R&D
-
Improved fine-tuning techniques
-
Integration with reinforcement learning
-
Exploration of unsupervised and self-supervised learning
-
Development of domain-specific and task-specific models
-
ปรับปรุงเทคนิคการปรับแต่งอย่างละเอียด
-
บูรณาการกับการเรียนรู้เสริมแรง
-
การสำรวจการเรียนรู้แบบไม่มีผู้ดูแลและการเรียนรู้ด้วยตนเอง
-
การพัฒนาโมเดลเฉพาะโดเมนและเฉพาะงาน
Future Applications of Prompt Engineering
-
Enhanced virtual assistants and chatbots
-
More accurate and efficient natural language processing tasks
-
Expansion into areas like healthcare, finance, and education
-
Ethical considerations and responsible AI development
-
ผู้ช่วยเสมือนและแชทบอทที่ได้รับการปรับปรุง
-
งานประมวลผลภาษาธรรมชาติที่แม่นยำและมีประสิทธิภาพยิ่งขึ้น
-
ขยายไปสู่ด้านต่างๆ เช่น การดูแลสุขภาพ การเงิน และการศึกษา
-
ข้อพิจารณาด้านจริยธรรมและการพัฒนา AI อย่างมีความรับผิดชอบ
Key Takeaways
-
Importance of well-designed prompts for effective AI solutions
-
Best practices for prompt design and optimization
-
Advanced techniques for improved performance
-
Future trends and areas of growth in prompt engineering
-
ความสำคัญของคำแนะนำที่ออกแบบมาอย่างดีสำหรับโซลูชัน AI ที่มีประสิทธิภาพ
-
แนวทางปฏิบัติที่ดีที่สุดสำหรับการออกแบบและการเพิ่มประสิทธิภาพที่รวดเร็ว
-
เทคนิคขั้นสูงเพื่อประสิทธิภาพที่ดีขึ้น
-
แนวโน้มในอนาคตและพื้นที่ของการเติบโตในด้านวิศวกรรมที่รวดเร็ว
Conclusion
-
Congratulations on completing the course
-
Encouragement to apply the knowledge gained in real-world applications
-
Invitation for feedback and questions
-
ยินดีด้วยที่จบหลักสูตร
-
ส่งเสริมให้นำความรู้ที่ได้รับไปประยุกต์ใช้งานจริง
-
คำเชิญสำหรับข้อเสนอแนะและคำถาม
Conclusion

แหล่งข้อมูลอ้างอิง
https://www.facebook.com/groups/988867541235062 Thailand Deep Learning https://docs.google.com/spreadsheets/d/1re_sxB43_2c8C_syWED5237bk6rtTEQ74uA63yMBYs4/edit?usp=sharing 2,008 ChatGPT Prompts PromptBase.com https://platform.openai.com/playground OpenAI.com
https://designer.microsoft.com/
Micirosoft Designer
deck
By Chatchailim Lim
deck
- 123