Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
Follow the authors
OK
Prompt Engineering for Generative AI: Future-Proof Inputs for Reliable AI Outputs
Purchase options and add-ons
Large language models (LLMs) and diffusion models such as ChatGPT and Stable Diffusion have unprecedented potential. Because they have been trained on all the public text and images on the internet, they can make useful contributions to a wide variety of tasks. And with the barrier to entry greatly reduced today, practically any developer can harness LLMs and diffusion models to tackle problems previously unsuitable for automation.
With this book, you'll gain a solid foundation in generative AI, including how to apply these models in practice. When first integrating LLMs and diffusion models into their workflows, most developers struggle to coax reliable enough results from them to use in automated systems. Authors James Phoenix and Mike Taylor show you how a set of principles called prompt engineering can enable you to work effectively with AI.
Learn how to empower AI to work for you. This book explains:
- The structure of the interaction chain of your program's AI model and the fine-grained steps in between
- How AI model requests arise from transforming the application problem into a document completion problem in the model training domain
- The influence of LLM and diffusion model architecture—and how to best interact with it
- How these principles apply in practice in the domains of natural language processing, text and image generation, and code
- ISBN-10109815343X
- ISBN-13978-1098153434
- Edition1st
- PublisherO'Reilly Media
- Publication dateJune 25, 2024
- LanguageEnglish
- Dimensions7.25 x 0.75 x 9.5 inches
- Print length422 pages
Frequently bought together

Customers who viewed this item also viewed
- AI Engineering: Building Applications with Foundation ModelsPaperbackFREE Shipping by AmazonGet it as soon as Sunday, Sep 20
- Co-Intelligence: Living and Working with AIHardcoverFREE Shipping on orders over $35 shipped by AmazonGet it as soon as Sunday, Sep 20
- Prompt Engineering for LLMs: The Art and Science of Building Large Language Model-Based ApplicationsPaperbackFREE Shipping by AmazonGet it as soon as Monday, Sep 21
- Designing Machine Learning Systems: An Iterative Process for Production-Ready ApplicationsPaperbackFREE Shipping by AmazonGet it as soon as Sunday, Sep 20
- Hands-On Large Language Models: Language Understanding and GenerationPaperbackFREE Shipping by AmazonGet it as soon as Monday, Sep 21
- AI Prompt Engineering: Foundations of Communication with LLMs – Building Generative AI and Agentic AI Prompt Systems Across Development, Testing, and DeploymentPaperbackFREE Shipping on orders over $35 shipped by AmazonGet it as soon as Monday, Sep 21
Customers also bought or read
- Prompt Engineering for LLMs: The Art and Science of Building Large Language Model-Based Applications
Paperback$54.51$54.51FREE delivery Mon, Sep 21 - AI-Assisted Programming: Better Planning, Coding, Testing, and Deployment
Paperback$39.20$39.20FREE delivery Sun, Sep 20 - AI Engineering: Building Applications with Foundation Models#1 Best SellerEnterprise Applications
Paperback$52.40$52.40FREE delivery Sun, Sep 20 - Building Applications with AI Agents: Designing and Implementing Multiagent Systems
Paperback$56.44$56.44FREE delivery Sun, Sep 20 - Hands-On Large Language Models: Language Understanding and Generation
Paperback$37.68$37.68FREE delivery Mon, Sep 21 - Generative AI Design Patterns: Solutions to Common Challenges When Building GenAI Agents and Applications
Paperback$68.99$68.99FREE delivery Sun, Sep 20 - LLM Engineer's Handbook: Master the art of engineering large language models from concept to production
Paperback$39.99$39.99FREE delivery Mon, Sep 21 - Learning LangChain: Building AI and LLM Applications with LangChain and LangGraph
Paperback$55.01$55.01FREE delivery Sun, Sep 20 - Building LLMs for Production: Enhancing LLM Abilities and Reliability with Prompting, Fine-Tuning, and RAG
Paperback$43.38$43.38FREE delivery Mon, Sep 21 - Unlocking Data with Generative AI and RAG: Enhance generative AI systems by integrating internal data with large language models using RAG
Paperback$44.99$44.99FREE delivery Mon, Sep 21 - Generative AI on AWS: Building Context-Aware Multimodal Reasoning Applications
Paperback$42.63$42.63FREE delivery Sun, Sep 20 - Build a Large Language Model (From Scratch)#1 Best SellerComputer Neural Networks
Paperback$49.24$49.24FREE delivery Sun, Sep 20 - Building LLM Powered Applications: Create intelligent apps and agents with large language models
Paperback$39.99$39.99FREE delivery Mon, Sep 21 - AI Agents in Action: Build, orchestrate, and deploy autonomous multi-agent systems
Paperback$59.99$59.99 - AI Prompt Engineering: Foundations of Communication with LLMs – Building Generative AI and Agentic AI Prompt Systems Across Development, Testing, and Deployment
Just releasedPaperback$31.67$31.67Delivery Mon, Sep 21 - The Art of Prompt Engineering with chatGPT: A Hands-On Guide (Learn AI Tools the Fun Way!)
Paperback$27.50$27.50Delivery Mon, Sep 21 - Hands-On Generative AI with Transformers and Diffusion Models
Paperback$45.20$45.20FREE delivery Sun, Sep 20 - Building AI Agents with LLMs, RAG, and Knowledge Graphs: A practical guide to autonomous and modern AI agents
Paperback$41.99$41.99FREE delivery Mon, Sep 21 - LLMs in Production: From language models to successful products
Paperback$48.13$48.13FREE delivery Sun, Sep 20 - Designing Machine Learning Systems: An Iterative Process for Production-Ready Applications
Paperback$40.00$40.00FREE delivery Sun, Sep 20 - Agentic Coding with Claude Code: The everyday developer's guide to agentic coding with Claude Code
Paperback$36.33$36.33FREE delivery Mon, Sep 21 - Generative Deep Learning: Teaching Machines To Paint, Write, Compose, and Play
Paperback$47.37$47.37FREE delivery Sun, Sep 20 - Context Engineering for Multi-Agent Systems: Move beyond prompting to build a Context Engine, a transparent architecture of context and reasoning
Paperback$37.99$37.99FREE delivery Mon, Sep 21 - Designing Multi-Agent Systems: Principles, Patterns, and Implementation for AI Agents
Paperback$46.39$46.39FREE delivery Mon, Sep 21 - Developing Apps with GPT-4 and ChatGPT: Build Intelligent Chatbots, Content Generators, and More
Paperback$20.74$20.74Delivery Tue, Sep 22 - Generative AI with LangChain: Build production-ready LLM applications and advanced agents using Python, LangChain, and LangGraph
Paperback$41.99$41.99FREE delivery Mon, Sep 21 - Essential Math for AI: Next-Level Mathematics for Efficient and Successful AI Systems
Paperback$44.14$44.14FREE delivery Sun, Sep 20
From the brand
-
Machine Learning, AI & more
-
Machine Learning
-
Artificial Intelligence
-
Deep Learning
-
Language Processing (NLP, LLM)
-
Sharing the knowledge of experts
O'Reilly's mission is to change the world by sharing the knowledge of innovators. For over 40 years, we've inspired companies and individuals to do new things (and do them better) by providing the skills and understanding that are necessary for success.
Our customers are hungry to build the innovations that propel the world forward. And we help them do just that.
From the Publisher
From the Preface
The rapid pace of innovation in generative AI promises to change how we live and work, but it’s getting increasingly difficult to keep up. The number of AI papers published on arXiv is growing exponentially, Stable Diffusion has been among the fastest growing open source projects in history, and AI art tool Midjourney’s Discord server has tens of millions of members, surpassing even the largest gaming communities. What most captured the public’s imagination was OpenAI’s release of ChatGPT, which reached 100 million users in two months, making it the fastest-growing consumer app in history. Learning to work with AI has quickly become one of the most in-demand skills.
Everyone using AI professionally quickly learns that the quality of the output depends heavily on what you provide as input. The discipline of prompt engineering has arisen as a set of best practices for improving the reliability, efficiency, and accuracy of AI models. “In ten years, half of the world’s jobs will be in prompt engineering,” claims Robin Li, the cofounder and CEO of Chinese tech giant Baidu. However, we expect prompting to be a skill required of many jobs, akin to proficiency in Microsoft Excel, rather than a popular job title in itself. This new wave of disruption is changing everything we thought we knew about computers. We’re used to writing algorithms that return the same result every time—not so for AI, where the responses are non-deterministic. Cost and latency are real factors again, after decades of Moore’s law making us complacent in expecting real-time computation at negligible cost. The biggest hurdle is the tendency of these models to confidently make things up, dubbed hallucination, causing us to rethink the way we evaluate the accuracy of our work.
We’ve been working with generative AI since the GPT-3 beta in 2020, and as we saw the models progress, many early prompting tricks and hacks became no longer necessary. Over time a consistent set of principles emerged that were still useful with the newer models, and worked across both text and image generation. We have written this book based on these timeless principles, helping you learn transferable skills that will continue to be useful no matter what happens with AI over the next five years. The key to working with AI isn’t “figuring out how to hack the prompt by adding one magic word to the end that changes everything else,” as OpenAI cofounder Sam Altman asserts, but what will always matter is the “quality of ideas and the understanding of what you want.” While we don’t know if we’ll call it “prompt engineering” in five years, working effectively with generative AI will only become more important.
Editorial Reviews
Review
—Dan Shipper, cofounder & CEO, Every
"This book is a solid introduction to the fundamentals of prompt engineering and generative AI. The authors cover a wide range of useful techniques for all skill levels from beginner to advanced in a simple, practical, and easy-to-understand way. If you're looking to improve the accuracy and reliability of your AI systems, this book should be on your shelf."
-Mayo Oshin, founder and CEO, Siennai Analytics, early LangChain contributor
"Phoenix and Taylor's guide is a lighthouse amidst the vast ocean of generative AI. Their book became a cornerstone for my team at Phiture AI Labs, as we learned to harness LLMs and diffusion models for creating marketing assets that resonate with the essence of our clients' apps and games. Through prompt engineering, we've been able to generate bespoke, on-brand content at scale. This isn't just theory; it's a practical masterclass in transforming AI's raw potential into tailored solutions, making it an essential read for developers looking to elevate their AI integration to new heights of creativity and efficiency."
—Moritz Daan, Founder/Partner, Phiture Mobile Growth Consultancy
"Prompt Engineering for Generative AI is probably the most future-proof way of future-proofing your tech career. This is without a doubt the best resource for anyone working in practical applications of AI. The rich, refined principles in here will help both new and seasoned AI engineers stay on top of this very competitive game for the foreseeable future."
- Ellis Crosby, CTO and cofounder, Incremento
"This is an essential guide for agency and service professionals. Integrating AI with service and client delivery, using automation management, and speeding up solutions will set new industry standards. You'll find useful, practical information and tactics in the book, allowing you to understand and utilize AI to its full potential."
- Byron Tassoni-Resch, CEO and cofounder, WeDiscover
From the Author
The Five Principles of Prompting are:
- Give Direction: Describe the desired style in detail, or reference a relevant persona.
- Specify Format: Define what rules to follow, and the required structure of the response.
- Provide Examples: Insert a diverse set of test cases where the task was done correctly.
- Evaluate Quality: Identify errors and rate responses, testing what drives performance.
- Divide Labor: Split tasks into multiple steps, chained together for complex goals.
We first published these principles as a blog post in July 2022, and they have stood the test of time, including mapping quite closely to OpenAI's own Prompt Engineering Guide, which came a year later. Anyone who works closely with generative AI is likely to converge on a similar set of strategies for solving common issues, but this book is designed to get you there quicker.
Throughout this book you'll see hundreds of demonstrative examples of prompting techniques, including both text and image prompting, as well as using Python to build AI automation scripts and products. This isn't a list of prompting hacks to find the right combination of magic words, it's a practical guide for building systems that provide the right context to AI applications, as well as how to test and scale AI systems for production.
The book will be useful for you if:
- Your time is worth more than 40 dollars an hour, and saving a few hours reading this book instead of piecing everything together from multiple sources is worth it to you.
- You're not just using AI casually but you're actually building an AI application or internal template many people will use hundreds or thousands of times a day.
- You want tips for reducing hallucination and improving the reliability of AI, while learning from 100s of real-world examples of how to solve common issues working with AI.
- You'd like to compare the strengths and weaknesses of OpenAI vs other models, as well as common frameworks like LangChain, different vector database options, and AUTOMATIC1111
- You want to see what it looks like to build an end-to-end AI application, from a naive prompt to a full AI agent, including building a basic user interface with Gradio
About the Author
Mike Taylor built and ran a 50-person marketing agency, including working on innovation projects with Unilever, Nestle, and Facebook. Over 300,000 people have taken his marketing courses on LinkedIn Learning.
Product details
- Publisher : O'Reilly Media
- Publication date : June 25, 2024
- Edition : 1st
- Language : English
- Print length : 422 pages
- ISBN-10 : 109815343X
- ISBN-13 : 978-1098153434
- Item Weight : 7.4 ounces
- Dimensions : 7.25 x 0.75 x 9.5 inches
- Best Sellers Rank: #94,452 in Books (See Top 100 in Books)
- #12 in Machine Theory (Books)
- #25 in Computer Neural Networks
- #29 in Natural Language Processing (Books)
- Customer Reviews:
About the authors

James Phoenix has a background in building reliable data pipelines and software for marketing teams, including automation of thousands of recurring marketing tasks. He has taught 60+ Data Science bootcamps for General Assembly.

I graduated with a master’s degree in Economics, then worked across a number of growth roles at startups, before co-founding a marketing agency and growing it to 50 people. After exiting I created courses on LinkedIn and Udemy taken by over 350,000 people, wrote a self-published book called Marketing Memetics, and a book for O'Reilly on Prompt Engineering for Generative AI. Today, I'm focused on building AI products through Brightpool.













