29,99 €
This book is designed for mastering prompt engineering in artificial intelligence, focusing on ChatGPT, GPT-4, and GPT plug-ins. It explores fundamental principles, practical techniques, and real-world applications. Readers will learn the role of prompts in AI interactions, the anatomy of well-constructed prompts, and various prompt styles. The book also covers setting constraints to guide AI responses and ensure ethical interactions, making it ideal for both beginners and advanced users.
The journey begins with the foundations of prompts and crafting contextual prompts. It progresses to asking specific questions, providing constraints, and creating diverse content prompts. Advanced chapters cover debugging, iterating prompts, and using GPT-4 with plug-ins. The book concludes with real-world applications, future trends, and ethical considerations, ensuring a comprehensive understanding of prompt engineering.
Understanding these concepts is crucial for effective AI interactions. This book transitions readers from basic to advanced prompt engineering, blending theoretical knowledge with practical skills. It is an essential resource for mastering prompt engineering and building innovative GPT applications.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 174
Veröffentlichungsjahr: 2024
PROMPT ENGINEERINGUSING CHATGPT
LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY
By purchasing or using this book and companion files (the “Work”), you agree that this license grants permission to use the contents contained herein, including the disc, but does not give you the right of ownership to any of the textual content in the book / disc or ownership to any of the information or products contained in it. This license does not permit uploading of theWork onto the Internet or on a network (of any kind) without the written consent of the Publisher. Duplication or dissemination of any text, code, simulations, images, etc. contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the Publisher or the owner of the content, etc., in order to reproduce or network any portion of the textual material (in any media) that is contained in the Work.
MERCURY LEARNING AND INFORMATION (“MLI” or “the Publisher”) and anyone involved in the creation, writing, or production of the companion disc, accompanying algorithms, code, or computer programs (“the software”), and any accompanying Web site or software of the Work, cannot and do not warrant the performance or results that might be obtained by using the contents of the Work. The author, developers, and the Publisher have used their best efforts to ensure the accuracy and functionality of the textual material and/or programs contained in this package; we, however, make no warranty of any kind, express or implied, regarding the performance of these contents or programs. The Work is sold “as is” without warranty (except for defective materials used in manufacturing the book or due to faulty workmanship).
The author, developers, and the publisher of any accompanying content, and anyone involved in the composition, production, and manufacturing of this work will not be liable for damages of any kind arising out of the use of (or the inability to use) the algorithms, source code, computer programs, or textual material contained in this publication. This includes, but is not limited to, loss of revenue or profit, or other incidental, physical, or consequential damages arising out of the use of this Work.
The sole remedy in the event of a claim of any kind is expressly limited to replacement of the book and/or files, and only at the discretion of the Publisher. The use of “implied warranty” and certain “exclusions” varies from state to state and might not apply to the purchaser of this product.
PROMPT ENGINEERINGUSING CHATGPT
Crafting Effective Interactions and Building GPT Apps
MEHRZAD TABATABAIAN, PHD, PENG
MERCURY LEARNING AND INFORMATIONBoston, Massachusetts
Copyright ©2024 by MERCURY LEARNING AND INFORMATION.An Imprint of DeGruyter Inc. All rights reserved.
This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in a retrieval system of any type, or transmitted by any means, media, electronic display or mechanical display, including, but not limited to, photocopy, recording, Internet postings, or scanning, without prior permission in writing from the publisher.
Publisher: David Pallai
MERCURY LEARNING AND INFORMATION
121 High Street, 3rd Floor
Boston, MA 02110
www.merclearning.com
800-232-0223
M. Tabatabaian. Prompt Engineering Using ChatGPT: Crafting Effective Interactions and Building GPT Apps.
ISBN: 978-1-50152-241-3
The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others.
Library of Congress Control Number: 2024932238
242526321 This book is printed on acid-free paper in the United States of America.
Our titles are available for adoption, license, or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at 800-232-0223(toll free).
All of our titles are available in digital format at academiccourseware.com and other digital vendors. The sole obligation of MERCURY LEARNING AND INFORMATION to the purchaser is to replace the files, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product.
This work is respectfully dedicated to the visionaries advancing our technological frontiers and to each reader endeavoring to use AI for the betterment of humanity.
CONTENTS
Preface
Introduction
History of LLM and GPT
About the Author
CHAPTER 1: FOUNDATIONS OF PROMPTS
1.1 The Role of Prompts in Interacting with ChatGPT
1.2 Anatomy of a Well-Constructed Prompt
The Essence of Clarity and Specificity
Harnessing the Power of Context
Avoiding Leading or Biased Language
1.3 Exploring Different Prompt Styles
Interrogative Prompts: Seeking Direct Answers
Imperative Prompts: Issuing Commands
Declarative Prompts: Providing Context or Information
Conversational Prompts: Fostering Dialogue
1.4 Prompt Examples and Analysis
Engineering and Technical Fields
Creative Writing and Content Generation
Healthcare and Medical Research:
Conversational AI and Virtual Assistants:
Educational and Learning Applications:
Role-Goal-Context Style:
CHAPTER 2: CRAFTING CONTEXTUAL PROMPTS
2.1 Leveraging Context for More Relevant Responses
2.2 Harnessing Prior Chat Turns for Smooth Conversations
2.3 Incorporating the User’s Name and Details for Personalization
CHAPTER 3: ASKING SPECIFIC QUESTIONS
3.1 Techniques for Asking Clear and Direct Questions
3.2 Navigating Ambiguity: How to Get Precise Answers
The Ambiguity Conundrum
3.3 Uncovering Hidden Information with Well-Formed Queries
CHAPTER 4: PROVIDING CONSTRAINTS AND GUIDELINES
4.1 Setting Constraints for Desired Output
The Role of Constraints in AI Interaction
4.2 Ensuring Ethical and Responsible Responses
Ethics in AI: A Fundamental Imperative
4.3 Combining Constraints for Tailored Content
The Synergy of Multiple Constraints
CHAPTER 5: CREATIVE PROMPTS FOR DIVERSE CONTENT
5.1 Inspiring Creative Writing with Open-Ended Prompts
Fostering Creativity Through Openness
5.2 Generating Poetry, Stories, and Dialogues
AI as a Creative Muse
5.3 Using Prompts to Generate Ideas and Concepts
Prompts as Creative Catalysts
5.4 Exploring Creativity through Multimodal Prompts
The Power of Multimodal Creativity
CHAPTER 6: DEBUGGING AND ITERATING PROMPTS
6.1 Interpreting and Analyzing Model Responses
Deciphering Model Outputs
6.2 Identifying Misunderstandings and Errors
The Challenge of Misunderstandings
6.3 Strategies for Iterating and Improving Prompts
The Iterative Prompt Refinement Cycle
CHAPTER 7: ADVANCED PROMPT ENGINEERING
7.1 Using Temperature, Top-p, and Max Tokens for Control
Temperature: Modulating Creativity
Top-p (Nucleus Sampling): Ensuring Relevance
Max Tokens: Limiting Response Length
7.2 Incorporating Conditional Logic in Prompts
Conditional Logic: Steering Model Responses
7.3 Dynamic Prompts for Interactive Experiences
CHAPTER 8: EFFECTIVE USE OF PROMPTS AND GPT-4 WITH PLUGINS
8.1 An Introduction to Plugins
8.2 Integrating Plugins for Enhanced AI Conversations
How To Get Plugins
8.3 Benefits of Using Plugins
8.4 Popular ChatGPT/GPT-4 Plugins
CHAPTER 9: REAL-WORLD APPLICATIONS
9.1 Applying Prompt Engineering in Customer Support
Enhancing Customer Support with Prompt Engineering
9.2 Generating Content for Social Media and Marketing
Transforming Social Media with AI-Powered Content
9.3 Educational Use Cases: Teaching and Learning with ChatGPT
Transforming Education with AI-Powered Chatbots
9.4 Business Applications
Enhancing Business Operations with AI Chatbots
9.5 Technical and Engineering Applications
CHAPTER 10: FUTURE TRENDS AND ETHICAL CONSIDERATIONS
10.1 The Evolving Landscape of AI-Generated Content
The Unfolding Revolution of AI-Generated Content
10.2 Addressing Bias and Fairness in Prompts and Responses
The Perils of Bias in AI-Generated Content
10.3 Ethical Considerations for Prompt Engineering
Ethical Imperatives in Prompt Engineering
CHAPTER 11: GPTS AND GPT APPLICATION BUILDER
11.1 New Features Announced with GPTs
11.2 How to Build GPTs
11.3 Example 1- A GPT App for Coloring Pages
11.4 Example 2- A GPT App for Story Writers
11.5 Winding down the ChatGPT plugins
11.5.1 Case Study 1: Prompt Professor
11.5.2 Case Study 2: Wolfram
11.5.3 Case Study 3: Scholar GPT
11.5.4 Case Study 4: Finance Wizard
11.5.5 Case Study 5: The Designer’s Mood Board
11.6 The Future of GPTs and GPT Builder
APPENDIX A: MISCELLANEOUS TOPICS
A.1 Topics for Future Research and Development in AI
A.2 Teaching with AI
Your Personal Interactive Tutor
A.3 Multimodal GPT-4 with Voice and Image as Prompts
TopAI.Tools
A.4 Common Pitfalls and Solutions
APPENDIX B: GLOSSARY
REFERENCES
INDEX
PREFACE
Preface
Welcome to an expedition into the realm of prompt engineering, where the art of language meets the science of artificial intelligence (AI). This book is a gateway to understanding the intricate process of crafting effective prompts, with a special emphasis on ChatGPT and its advanced iterations, including GPT-4 and GPTs, the ground-breaking innovations from OpenAI (https://openai.com/). Whether you are a student fascinated by the vast potential of AI or a professional trying to harness its power for practical applications, this guide is designed to provide you with the essential knowledge and techniques for effective interaction with AI systems.
AI for All
Our journey is for a diverse audience, encompassing everyone from AI novices to seasoned practitioners. The world of GPT-based models can be complex and intimidating, especially for those without a background in data or computer science. Our mission is to make this world accessible to all. Through a blend of clear, natural language and practical, real-world examples, we aim to demystify the nuances of prompt engineering, equipping you with the tools and confidence to communicate effectively with AI systems.
A Deep Dive into ChatGPT and Beyond
Although there are so many AI innovations, like GeminiTM, Bing ChatTM, ClaudeTM, and LlamasTM, our focus is on ChatGPT and its iterations. This choice was driven by our goal to introduce you to the foundational principles of prompt engineering and empower you to fully leverage the capabilities of ChatGPT and similar advanced models. We want you to understand all the possibilities within the field of AI, relevant to prompt engineering.
The Ever-Evolving Field of AI
The field of AI is dynamic and ever-changing, and so is the art and science of prompt engineering. As you read this book, you will explore the foundational techniques, delve into practical strategies, and discover real-world applications of prompt engineering. In an age where AI technology continues to rapidly change, mastering the skill of crafting effective prompts is invaluable. It paves the way for creative, efficient, and ethical interactions with AI systems, unlocking new opportunities in various domains. This rapid advancement in AI brings with it a host of challenges, from managing the effects of the speed of AI development to harnessing the power of AI/GPT for AI. This book aims to equip you with the knowledge and skills needed to navigate this evolving landscape successfully.
From Theory to Practice: Real-World Insights
This book is not just a theoretical exploration; it is a practical guide. We directly apply the principles of prompt engineering using ChatGPT-3.5 and GPT-4. Through these applications, we demonstrate the creation of prompts that lead to clear, effective communication. The content generated using these models has been thoroughly reviewed and refined for clarity and effectiveness, throughout this book’s content. However, as AI technology evolves, so do its responses. The examples in this book serve as a snapshot of current capabilities, with the understanding that AI’s language and responses will continue to advance.
A Personal Invitation to AI Mastery
We thank you for choosing to embark on this journey of discovery with us. As we guide you through the dynamic and ever-evolving landscape of AI-generated content, we share our insights, experiences, and passion for one of the most transformative aspects of modern technology. This book is a guide to help you explore AI, a tool to unlock the mysteries of prompt engineering, and a bridge to the future of human-AI interaction.
Managing the Ethics involved with AI and GPT
As we embark on this exploration of prompt engineering, it is imperative to navigate the intricate ethical landscape intertwined with the swift advancement of technologies like GPT and AI. The rapid progress of GPT and AI raises an array of pressing questions and considerations. These encompass ethical dilemmas, moral implications, the establishment of regulatory frameworks, the need to address dominance limitations, issues pertaining to social justice, the necessity of acquiring new skills, the disruptive impact on job markets, and the preservation of fundamental human rights—all serious issues that require prompt attention. As we explore the dynamic realm of prompt engineering, it is vital to acknowledge that these concerns are not mere afterthoughts but integral facets of the AI journey. They serve as a clarion call, summoning the imperative for ongoing research and development within the field of AI.
This book encompasses the following chapters:
Chapter 1: Foundations of Prompts. This chapter provides the fundamental groundwork for understanding prompts, their role in guiding AI models, and their impact on the quality of generated responses.
Chapter 2: Crafting Contextual Prompts. This chapter explores the art of constructing prompts that allow for rich and context-aware interactions with AI models.
Chapter 3: Asking Specific Questions. This chapter describes techniques for formulating clear and direct questions to obtain precise answers from AI models.
Chapter 4: Providing Constraints and Guidelines. This chapter demonstrates how to set constraints and guidelines in your prompts to steer AI responses towards desired outcomes and ethical considerations.
Chapter 5: Creative Prompts for Diverse Content. This chapter explores the creative possibilities of prompts, including those for generating content, ideas, and multimodal responses.
Chapter 6: Debugging and Iterating Prompts. This chapter discusses strategies for evaluating and improving prompts, ensuring they yield the desired results in interactions with AI models.
Chapter 7: Advanced Prompt Engineering. This chapter investigates advanced techniques, including plugins and conditional logic, to harness the full potential of AI models.
Chapter 8: Effective Use of Prompts and GPT-4 Plugins. This chapter discusses how to leverage plugins to extend the capabilities of GPT-4 and create more versatile AI-powered applications.
Chapter 9: Real-World Applications. This chapter demonstrates how prompt engineering is applied across various domains, from customer support and education to business and technical fields.
Chapter 10: Future Trends and Ethical Considerations. This chapter explores the evolving landscape of AI-generated content and delves into ethical considerations as AI technology continues to advance.
Chapter 11: GPTs and GPT Application Builder. This chapter is designed to guide users through the versatile capabilities of the GPTs framework and GPT Builder tool.
Appendix A: Miscellaneous Topics. This section covers a range of additional topics related to prompt engineering, offering practical insights and resources.
Appendix B: Glossary. This section provides a list of important terms and definitions to aid in understanding the terminology of prompt engineering and AI technology.
Acknowledgment
I wish to extend my gratitude to David Pallai from Mercury Learning and Information, my publisher, for his invaluable support.
Mehrzad Tabatabaian, PhD, PEngVancouver, BCMay 2, 2024
INTRODUCTION
In the rapidly evolving landscape of artificial intelligence (AI), ChatGPT has emerged as a powerhouse, offering unprecedented capabilities in generating human-like text and speech. As AI becomes an integral part of various domains, understanding how to effectively craft prompts for ChatGPT is essential to unlock its full potential and achieve desired outcomes.
At the heart of this exploration lies the recognition that well-written prompts can ensure seamless communication with ChatGPT. Drawing a parallel to the role of a skilled pilot skillfully guiding an aircraft through the skies, well-constructed prompts take on the critical task of steering and shaping the trajectory of responses crafted by ChatGPT.
ChatGPT is a well-trained mathematical model at the forefront of conversational AI. At its core, it relies on the next-token mathematical model, a fundamental framework that underpins its remarkable conversational abilities. Operating on the principles of probability and deep learning, this model has been meticulously trained on an extensive and diverse dataset. It excels at comprehending the intricacies of language, allowing it to analyze the context and generate responses with remarkable coherence and relevance. When presented with a user’s input, it deploys intricate algorithms to predict the most likely next word or token, resulting in responses that not only feel natural, but are also tailored to the ongoing conversation. This mathematical foundation empowers ChatGPT to excel in a wide array of conversational contexts, providing users with an exceptional conversational experience that is coherent, contextually aware, and highly adaptable.
Prompt engineering is the beginning of the journey into the art and science of shaping interactions with this cutting-edge AI language model. This book is your guide to mastering this orchestration, understanding the nuances of prompts, and harnessing their power for a wide array of applications. As we embark on this journey, we will uncover the intricacies of prompt engineering, delve into the psychology of effective communication, and discover how to make ChatGPT’s responses align with specific objectives. There are many possibilities, from refining the phrasing of a question to imbuing context into a conversation.
Adding to this is the revolutionary emergence of GPT App Builders, platforms enabling individuals and organizations to design custom applications powered by the linguistic capabilities of GPT. These builders offer a user-friendly interface to create, experiment, and deploy applications tailored to specific needs or industries. By incorporating GPT App Builders, we can refine the conversation and revolutionize the application of conversational AI in various sectors. They serve as the bridge between technical prowess and practical application, making it possible for anyone, from developers to business and technical leaders, to create personalized AI-driven solutions.
Join us in unraveling the art of prompt engineering, a skill that empowers us to bridge the gap between human thought and AI-generated text, and to create a harmonious partnership that transforms the way we interact with technology.
Figure I.1 shows the relationships among AI, NLP, and other subfields.
FIGURE I.1 A flowchart showing AI and its subfields.
HISTORY OF LLM AND GPT
Language Models (LMs) and Large Language Models (LLMs) like GPT (Generative Pre-trained Transformer) have revolutionized the field of natural language processing (NLP) and data science. The history of LLMs can be traced back to the early days of machine learning and artificial intelligence, where researchers began exploring methods to teach machines to understand and generate human language. Early attempts, such as rule-based systems and statistical language models, had limitations in capturing the nuances and complexities of human language.
The breakthroughs in LLMs came in the form of deep learning and neural networks. The concept of pre-training, where models learn from vast amounts of text data before fine-tuning on specific tasks, became pivotal. In 2018, OpenAI introduced the first GPT model, GPT-1. This model, with 117 million parameters, showed the potential of pre-trained language models for various NLP tasks. It laid the foundation for subsequent advancements. GPT-3, developed by OpenAI, made headlines in 2020 for its astonishing ability to generate coherent and contextually relevant text. It achieved this by leveraging a massive transformer architecture with 175 billion parameters, allowing it to capture intricate patterns and associations within language. In 2023, OpenAI released GPT-4, which was trained on 1.76 trillion parameters, making it the most advanced system to date.
Since then, the field has continued to evolve. Researchers are exploring ways to make LLMs more efficient, ethical, and applicable across various domains. Additionally, LLMs are being employed in diverse applications, including engineering and manufacturing, healthcare, content generation, education, and natural language understanding in virtual assistants. The list of applications is growing as time goes by, complemented with plugins for GPT-4 and multimodal models.
For the latest information on LLMs and GPT technologies, readers can refer to recent publications in top-tier conferences such as the Conference on Neural Information Processing Systems (NeurIPS) and the International Conference on Machine Learning (ICML). These conferences feature cutting-edge research in the field and provide insights into the latest advancements in LLM technology.
ABOUT THE AUTHOR
Dr. Mehrzad Tabatabaian is a faculty member at the Mechanical Engineering Department, School of Energy at the British Columbia Institute of Technology (BCIT). He has several years of teaching and industry experience. Dr. Tabatabaian is currently Chair of the BCIT School of Energy Research Committee. He has published several papers in scientific journals and for conferences and has written textbooks on Multiphysics and turbulent flow modelling, advanced thermodynamics, tensor analysis, direct energy conversion, the Bond Graph modelling method, and calculus. He holds several registered patents in the energy field, the results of years of research activities.
Dr. Tabatabaian volunteered to help establish the Energy Efficiency and Renewable Energy Division (EERED), a new division at Engineers and Geoscientists British Columbia (EGBC).
Dr. Tabatabaian received his BEng from Sharif University of Technology (formerly AUT) and holds advanced degrees from McGill University (MEng and PhD). He has been an active academic, professor, and engineer in leading alternative energy, oil, and gas industries. Dr. Tabatabaian also has a Leadership Certificate from the University of Alberta and holds an EGBC P.Eng. License.
CHAPTER 1
FOUNDATIONS OF PROMPTS