Digital Library

Introduction to Generative AI, Second Edition Reliable, responsible, and real-world applications (Numa Dhamani Maggie Engler)(Z-Library)

Numa Dhamani & Maggie Engler

Introduction to Generative AI, Second Edition Reliable, responsible, and real-world applications (Numa Dhamani Maggie Engler)(Z-Library)

Author Numa Dhamani & Maggie Engler

ai

No Description

Format PDF
Size 3.0 MB
13
Views
0
Downloads
0.00
Total Donations

Text Preview (First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
M A N N I N G Numa Dhamani ● Maggie Engler Foreword by Alice Hunsberger Reliable, responsible, and real-world applications SECOND EDITION Introduction to Generative AI
Page 2
MANN I NG Shelter ISland Numa Dhamani Maggie Engler Introduction to Generative AI Second Edition Foreword by Alice Hunsberger Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 3
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: orders@manning.com © 2026 Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid- free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. ∞ Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 ISBN 9781633434882 Printed in the United States of America The author and publisher have made every effort to ensure that the information in this book was correct at press time. The author and publisher do not assume and hereby disclaim any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause, or from any usage of the information herein. Development editor: Rebecca Johnson Review editor: Angelina LazukiÊ Production editor: Aleksandar DragosavljeviÊ Copy editor: Andy Carroll Proofreader: Mike Beady Typesetter: Tamara ŠveliÊ SabljiÊ Cover designer: Marija Tudor Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 4
Numa dedicates this book to her parents, Nazarali and Nadia, and her brother, Nihal. Maggie dedicates this book to her husband, Joe, and her daughter. Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 5
iv brief contents 1 ■ Large language models: The foundation of generative AI 1 2 ■ Training large language models: Learning at scale 36 3 ■ Data privacy and safety: Technical and legal controls 63 4 ■ AI and the creative economy: Innovation and intellectual property 105 5 ■ Misuse and adversarial attacks: Challenges and responsible testing 143 6 ■ Machine-augmented work: Productivity, education, and economy 197 7 ■ Prompt engineering: Strategies for guiding and evaluating LLMs 237 8 ■ AI agents: The rise of autonomous AI systems 270 9 ■ Human connections: The social role of chatbots 316 10 ■ The future of responsible AI: Risks, practices, and policy 349 11 ■ Frontiers of AI: Open questions and global trends 410 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 6
v contents foreword xii preface xiv acknowledgments xvi about this book xviii about the authors xxii about the cover illustration xxiv 1 Large language models: The foundation of generative AI 1 The evolution of natural language processing 3 The birth of LLMs 7 The explosion of LLMs 9 What are LLMs used for? 11 Language modeling 11  ■  Question answering 13  ■  Coding 14  ■  Content generation 15  ■  Logical reasoning 17 Other natural language tasks 18 Where do LLMs fall short? 19 Training data and bias 19  ■  Limitations in controlling machine outputs 22 Sustainability of LLMs 24 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 7
vi contents Major players in generative AI 25 OpenAI 26  ■  Google 28  ■  Meta 29 Microsoft 30  ■  Anthropic 31 Other notable players 32 Conclusion 34 2 Training large language models: Learning at scale 36 How are LLMs trained? 37 Exploring open web data collection 38 Demystifying autoregression and bidirectional token prediction 40 Training multimodal LLMs 41 Transferring knowledge for efficient models 44 Mixture of Experts and sparse models 46 Reasoning models 48 Techniques for post-training LLMs 51 Supervised fine-tuning 52  ■  Reinforcement learning from human feedback 53 Direct preference optimization 54 Reinforcement learning from AI feedback 55 Emergent properties of LLMs 56 Learning with a few examples 57 Is emergence an illusion? 60 Conclusion 61 3 Data privacy and safety: Technical and legal controls 63 What’s in the training data? 64 Encoding bias 64  ■  Linguistic diversity 69 Sensitive information 72 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 8
viicontents Safety-focused improvements for LLM generations 77 Post-processing detection algorithms 78 Content filtering or conditional pretraining 80 Safety post-training 81  ■  Machine unlearning 84 Navigating user privacy and commercial risks 86 Inadvertent data leakage 86  ■  Best practices when interacting with LLMs 89 Data protection and privacy in the age of AI 89 International standards and data protection laws 90  ■  Are generative AI systems GDPR- compliant? 94  ■  Privacy regulations in academia 97  ■  Corporate policies 98 Governing data in an AI-driven world 100 Conclusion 103 4 AI and the creative economy: Innovation and intellectual property 105 The rise of synthetic media 106 Techniques for creating synthetic media 107 The opportunities and risks of synthetic media 112  ■  Detecting synthetic media 114 Transforming creative workflows 119 Marketing and media applications 120 Visual and digital art 123 Filmmaking 124  ■  Music 125 Intellectual property in the LLM era 127 Copyright law and fair use 128  ■  Open source and licenses 136  ■  Creator’s rights and data licensing 139 Conclusion 141 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 9
viii contents 5 Misuse and adversarial attacks: Challenges and responsible testing 143 Intentional misuse 144 Cybersecurity and social engineering 145 Illicit and harmful applications 152 Adversarial narratives 160  ■  Political manipulation and electioneering 169 Hallucinations 174 Why do LLMs hallucinate? 174  ■  Misuse of LLMs in the professional world 182 Red teaming LLMs 189 Conclusion 194 6 Machine-augmented work: Productivity, education, and economy 197 Using LLMs in the professional space 198 LLMs assisting doctors with administrative tasks 198  ■  LLMs for legal research, discovery, and documentation 200 LLMs augmenting financial investing and bank customer service 204 LLMs as collaborators in creativity 205 LLMs as a programming partner 207 LLMs in daily life 211 Generative AI in education 218 Detecting machine-generated text 224 Generative AI and the labor market 230 Conclusion 235 7 Prompt engineering: Strategies for guiding and evaluating LLMs 237 What is prompt engineering? 238 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 10
ixcontents Prompting techniques and frameworks 244 Overview of common prompting techniques 245  ■  Structuring prompts to guide model behavior 246  ■  Prompting frameworks for structured output 252 Evolving practices in prompt engineering 254 Evaluating AI-generated outputs 258 Identifying evaluation metrics 258 Assembling evaluation datasets 259 Scoring model responses 261 Prompting vs. post-training 266 Conclusion 268 8 AI agents: The rise of autonomous AI systems 270 What is an AI agent? 271 How are AI agents being used? 272 Personal assistants 273  ■  Enterprise workflows 275  ■  Research and discovery 277 Software development 278  ■  Cybersecurity 282 Physical environments 283  ■  Multi-agent systems 284  ■  Toward agentic collaboration 285 How are AI agents trained and enabled? 286 Agent architectures 290  ■  Retrieval- augmented generation 292  ■  Model Context Protocol 295  ■  GUI-native agents 297 Evaluating agents 299 Risks and considerations unique to agents 301 Autonomy and misalignment 302  ■  Memory and state persistence 303  ■  Tool access and real-world consequences 304  ■  Emergent behaviors in multi-agent systems 305  ■  Security and adversarial risks 307  ■  Human factors and decision delegation 308  ■  Evaluation, monitoring, and oversight 309  ■  The road ahead 311 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 11
x contents The future of AI agents 311 Conclusion 314 9 Human connections: The social role of chatbots 316 The rise of human–chatbot relationships 317 Why humans are turning to chatbots for relationships 324 The loneliness epidemic 324  ■  Emotional attachment in human–chatbot relationships 327 The benefits and risks of human–chatbot relationships 331 Toward healthier human–chatbot relationships 340 Conclusion 347 10 The future of responsible AI: Risks, practices, and policy 349 Where are LLM developments headed? 350 Language as the universal interface 351 From tools to agentic systems 353  ■  The rise of personalized AI 355  ■  On the horizon 357 Sociotechnical risks of generative AI 359 Bias, toxicity, and representational harms 359 Hallucinations and fabrications 360 Privacy and data leakage 360  ■  Adversarial attacks and security vulnerabilities 361 Autonomy and emergent agentic risks 362 Misuse across domains 362  ■  Dependency, emotional harm, and relationship risks 363 Labor and economic disruption 364 A holistic view of harm 364 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 12
xicontents Best practices for responsible AI development and use 365 Curating datasets and standardizing documentation 366  ■  Protecting data privacy 368  ■  Explainability, transparency, and bias 370  ■  Design interventions and architectures 373  ■  Model training strategies for safety 376  ■  Red teaming and evaluation 379  ■  Detecting and tracing synthetic media 380  ■  Platform responsibility and user safeguards 383  ■  Humans in the loop 385  ■  Education and digital literacy 387  ■  Toward responsible generative AI 388 AI regulations in practice 389 The United States 389  ■  The European Union 394  ■  China 399  ■  Corporate self- governance 402 Toward an AI governance framework 405 Conclusion 408 11 Frontiers of AI: Open questions and global trends 410 The quest for artificial general intelligence 411 AI sentience and consciousness 420 The carbon footprint of LLMs 426 The open source movement 433 Global investment in AI 441 Conclusion 445 references 447 index 478 Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 13
xii foreword In just a few years, generative AI has become a daily tool for millions of people around the world. Even in the short time since the first edition of this book was published, generative AI has shifted from being an emerging and somewhat limited technology to powering countless new applications and startups. AI is changing the way that we work, interact, and even think. As someone who has red teamed an early version of a founda- tional model and now heads Trust & Safety at one such AI-powered startup, I’m certainly excited by the transformative potential of AI and the rapid pace at which it continues to improve and evolve. However, I have also seen the risks up close. Just as AI can be used to accelerate learning and discovery, it can also amplify the worst parts of our society. It can be used by bad actors as easily as good, and for extraction rather than enrichment. This dual nature fuels a public discourse that is often heated and polarized. Some say that AI is on the edge of saving humanity, while others are afraid that it will doom us all. The reality is that AI isn’t magic (even though it may seem like it sometimes), and it’s import- ant to know how it works, its potential pitfalls and limitations, and how to think critically about its use. Many of us are daily AI users, but without the foundational understanding to use these tools safely and effectively, it’s easy to misinterpret AI behavior or miss opportunities Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 14
xiiiforeword to steer it in the right direction. Whether you consider yourself a power user of generative AI, work on teams building tools that use it, or are just trying to understand more about a technology that is rapidly becoming embedded in all of our daily lives, I think you will find that this book is a valuable resource. What is needed most in this time is a balanced and educational per- spective, which is exactly what authors Numa Dhamani and Maggie Engler provide in these pages. They tackle the most complex issues head-on, with a clarity that doesn’t shy away from the nuanced and complicated details that are at the core of all ethical technology dis- cussions. While they give us a truly thorough lesson in understand- ing generative AI, this book is still accessible and straightforward. In the following chapters, you’ll read about the full spectrum of problems that may come about from the use of generative AI— everything from the exploitation and misuse of AI technology to the various forms of bias that can be found in training data to the tensions between lonely people and the potential for harm that can come from human attachment to inhuman AI. You’ll also learn about the oppor- tunities in using generative AI to be more productive, or to perform tasks that are repetitive or even harmful for people, such as content moderation of disturbing images or text that can be traumatic for frontline moderators. Finally, you’ll come away with a better under- standing of how AI is evolving and where we may be headed next, including the pursuit of human-level artificial general intelligence. While reading this book and thinking about what you learn here, I invite you to be curious and apply the critical and open-minded perspective that is much needed in this moment. AI systems must be designed to work for all of us and align with our values and systems. We must strike a careful balance between human and AI that aug- ments thoughtful human judgement rather than replacing it alto- gether. If you are in a position to do so, I invite you to educate others with what you have learned in these pages. I also hope that you will join me in aspiring to be a thoughtful and ethical builder and user of generative AI systems, so that we all may thrive. —Alice Hunsberger Head of Trust & Safety, Musubi Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 15
xiv preface Though it hardly seems possible, in the two years since the release of the first edition of Introduction to Generative AI, generative artificial intelligence has only grown in the public consciousness. Large lan- guage models (LLMs) were once a development exciting mostly to developers of natural language processing applications, like the two of us; now, the release of new models is covered breathlessly in the tech press. LLMs and multimodal models have already transformed the creation of text, images, audio, and video, and each passing day brings new applications that test the limits of AI capabilities. In this second edition, we again attempt to build an understand- ing of how LLMs are trained, the data they are trained on, and the algorithms that contribute to their final output, increasingly indis- tinguishable from what a human might produce. We have added new material on reasoning models and AI agents, among other updates that reflect the state of the industry today. But rather than uncritically reporting on these developments, we highlight their nuances and implications in addition to their fascinating technical foundations. The outputs of generative models and the products they make pos- sible have many beneficial and malicious uses alike. Their capabilities are unlike any systems we’ve seen before, but flashy performances Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 16
xvpreface on benchmarks such as standardized tests can obscure their severe limitations, including bias, hallucinations, and unsafe generations. Their production also raises important questions about legal rights and intellectual property protections, the ethics of human–AI inter- action, the economics of AI-assisted work, and so much more. In this volume, we’ve attempted to stake out our own positions, citing research papers and real-world examples. Two years after the publication of our first edition, these problems remain far from solved. Addressing these issues will be an iterative process that requires a whole-of-society response. It is our hope to encourage beginners, hobbyists, and experienced professionals alike to par- ticipate in the public conversation about generative AI. The field is still dominated by too few voices, leading to narrow conversations that neglect the perspectives of marginalized groups, wage workers, artists and creators, and myriad other cohorts affected by AI. An informed public is our greatest asset in creating the future that we want with generative AI. We hope that you’ll join us in the effort to shape a world where AI helps rather than supplants people, a world in which the central focus remains on the human experience. Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 17
xvi acknowledgments We would like to express our heartfelt appreciation to Alice Hunsberger, whose thoughtful and insightful foreword sets the tone for this book. Your leadership in trust and safety and your commit- ment to building more responsible digital systems inspire us, and your contribution has made this book all the more meaningful. This book would not have been possible without the help and sup- port of many of our friends and colleagues. In no particular order, we would like to thank David Sullivan, Erin McAuliffe, Natalija Bitiukova, Dr. Daniel Rogers, Sam Plank, Derek Slater, Reed Coke, Whitney Nelson, Karan Lala, Rebecca Ruppel, Michael Wharton, Dr. Kenneth R. Fleischmann, Dr. Alex Mably, Ryman Stringer, Jen Weedon, Brett Harvey, Aurora Quinn-Elmore, Oliver Emberton, Olya Gurevich, Mustafa Suleyman, Ram Shankar Siva Kumar, David Ryan Polgar, and Jeff Allen. All of these people provided valuable feedback and diverse perspectives that helped shape the ideas pre- sented in these pages. We would also like to thank the team at Manning who supported this second edition. Rebecca Johnson, our development editor, once again guided us through this process, providing feedback and coordinating all the various moving parts. Andy Waldron, our acquisitions editor, not only believed in this project from the very Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 18
xviiacknowledgments beginning but also encouraged us to take on a second edition. We would like to further acknowledge the reviewers who read the manu- script at various points and provided detailed feedback: Christopher Shehu, Danny Vinson, Deniz Acay, Dima Kuchin, Eelco den Heijer, Fadi Maali, Frances Buontempo, Germano Rizzo, Jaehyun Yeom, Jean-François Morin, Jeanne Boyarsky, John Esther, John Guthrie, Jon Humphrey, Julien Pohie, Maja Ferle, Matthew Copple, Michael Aydinbas, Serge Simon, Thomas Seeber, and Victor Durán. Your contributions made this book as helpful to our readers as possible. Above all, we want to thank you, our reader. Whether you’ve returned after the first edition or are picking up this book for the first time, we’re grateful you chose to spend time with it. Thank you for engaging with the implications of generative AI technology and considering how to balance innovation with responsibility. Thank you for taking these conversations to your colleagues, friends, and communities. You are helping us move toward a society that is informed, thoughtful, and considerate about generative AI. Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 19
xviii about this book Introduction to Generative AI, Second Edition, builds on the first edi- tion with revised content throughout and two entirely new chap- ters. Since the release of ChatGPT in late 2022, generative AI has rapidly become a global phenomenon, captivating the imagination of millions of users while also raising cautions from researchers, policymakers, and industry observers about its limitations and risks. This book provides a high-level introduction to generative AI with an emphasis on large language models (LLMs). We explain how generative models work, where they are being used, and both the promise and the risks that they pose. This second edition adds chapters on prompt engineering, cov- ering strategies for writing, refining, and evaluating prompts, and on AI agents, exploring how they are designed and where they are headed. It also goes into greater detail on developments such as retrieval-augmented generation, multimodal models, reason- ing capabilities, and Mixture of Experts systems. Beyond technical advances, this edition expands the book’s coverage of data gover- nance, licensing, and creator rights, and it takes a closer look at the global adoption of generative AI and its impact on education, labor, and investment. Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
Page 20
xixabout this book Throughout, we emphasize that generative AI presents deep soci- otechnical challenges, with technical progress and societal impact intertwined. Our goal is to make these ideas accessible to readers from a wide range of backgrounds. We share best practices for the safe and ethical use of generative AI, drawing on our combined experience in responsible technology, trust and safety, data security, and privacy. Who should read this book This book is written for anyone interested in generative AI and in understanding how to be a thoughtful and responsible participant in this area of innovation. While some familiarity with machine learning and natural language processing (NLP) concepts may be helpful, it’s not required. There is no code or math in this book— it is designed to be an accessible resource for those who want to build intuition about how generative AI works, the promises and risks it brings, and the broader societal, economic, and legal con- texts in which these systems operate. While this book doesn’t pro- vide a deep dive into the technical development and deployment of LLMs, Manning publishes several more technical books that cover these subjects in depth. We are hopeful that this book will be valuable not only for machine learning practitioners but also for policymakers, educators, industry professionals, and the general public. We can all play a role in shap- ing the responsible adoption of generative AI while benefiting from and enjoying technological progress. How this book is organized: A road map In the chapters of this book, we use the terms dialogue agent, chatbot, conversational agent, or conversational system interchangeably to refer to an AI system powered by a large language model and trained to engage in conversation with users (unless otherwise specified). When we refer to “model generations,” we mean the outputs pro- duced by a model (such as a block of text, an image, or another generated artifact), except where noted. Here’s a brief description of what you’ll see in each chapter: Licensed to Ibrahim Mohammed Mohammed <ibrahim@dotnetebusiness.com>
The above is a preview of the first 20 pages. Register to read the complete e-book.

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List