Leanpub Header

Skip to main content

AI ENGINEERING IN PRACTICE

From LLMs and RAG to Agentic AI Systems

AI ENGINEERING IN PRACTICE
This book is 100% completeLast updated on 2026-11-21

Move beyond AI experimentation and learn how to engineer real-world AI applications.

AI Engineering in Practice takes you from Large Language Models (LLMs) and Retrieval-Augmented Generation (RAG) to AI agents, multi-agent systems, LLMOps, AI security, and production-ready applications.

Featuring 18 comprehensive chapters, practical labs, real-world case studies, and engineering checklists, this textbook provides a complete learning pathway for students, developers, researchers, and technology professionals.

Learn the concepts. Understand the architectures. Build reliable AI systems. Prepare for the future of Agentic AI.

Minimum price

$12.99

$19.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
About

About

About the Book

About the Book

AI Engineering in Practice: From LLMs and RAG to Agentic AI Systems is a comprehensive, application-oriented textbook designed to help readers understand, build, evaluate, secure, and deploy modern AI-powered applications.

As Artificial Intelligence evolves beyond traditional machine learning and standalone chatbots, the ability to engineer reliable AI systems has become an essential technical skill. This book provides a structured learning pathway from the fundamentals of Large Language Models (LLMs) to advanced Retrieval-Augmented Generation (RAG), AI agents, multi-agent architectures, and production-ready AI applications.

The book covers the complete AI engineering lifecycle, combining conceptual explanations with practical engineering approaches, real-world application architectures, integrated case studies, and hands-on learning activities.

Across 18 carefully structured chapters, readers explore:

  • Large Language Models: Transformers, tokens, attention, model training, inference, context windows, and model selection.
  • LLM Application Engineering: Model APIs, structured outputs, function calling, conversation management, error handling, and reliability.
  • Retrieval-Augmented Generation (RAG): Document processing, embeddings, vector databases, semantic search, hybrid retrieval, and advanced knowledge systems.
  • Context Engineering: Context design, memory management, summarisation, context compression, and information retrieval.
  • AI Agents and Multi-Agent Systems: Agent architectures, planning, reasoning, tool execution, task delegation, coordination, and shared state.
  • AI System Evaluation: Evaluation datasets, groundedness, accuracy, LLM-as-a-Judge, and automated testing.
  • AI Security and Responsible AI: Prompt injection defence, privacy, data protection, governance, human oversight, and risk assessment.
  • Deployment and LLMOps: Cloud deployment, containers, observability, monitoring, tracing, performance optimisation, and cost management.
  • Fine-Tuning and Model Adaptation: Supervised fine-tuning, LoRA, parameter-efficient adaptation, and training data validation.
  • Enterprise and Multimodal AI: Business automation, intelligent document processing, image understanding, speech, video, and multimodal retrieval.
  • AI Product Development: MVP design, technology selection, product testing, deployment readiness, and operational planning.
What Makes This Book Valuable?

Rather than focusing only on AI theory or prompt-writing techniques, this textbook approaches AI from an engineering perspective. It explains how individual AI components work together to create dependable, scalable, secure, and useful applications.

The book also includes practical labs, integrated case studies, engineering checklists, review questions, and multiple-choice questions to reinforce learning and encourage practical implementation.

Who Should Read This Book?

This book is particularly suitable for:

  • Undergraduate and postgraduate computer science students.
  • Software developers and application engineers.
  • AI, Machine Learning, and Data Science learners.
  • Researchers exploring LLMs and Agentic AI.
  • University faculty members and technical educators.
  • IT professionals and technology consultants.
  • Entrepreneurs and professionals interested in AI-powered products.
Learning Outcomes

After studying this book, readers should be able to understand modern AI engineering architectures, integrate LLMs into applications, design RAG pipelines, develop agent-based workflows, evaluate AI system quality, identify security risks, implement responsible AI practices, and understand the essential steps involved in deploying AI-powered products.

AI Engineering in Practice is designed as both a learning resource and a practical reference for anyone interested in moving from experimenting with AI models to engineering complete AI systems.

Whether you are beginning your journey in AI application development or expanding your professional knowledge of advanced AI architectures, this book provides a structured foundation for understanding and applying modern AI engineering principles.

Author

About the Author

Anshuman Mishra

Anshuman Kumar Mishra, M.Tech (Computer Science) Assistant Professor, Doranda College, Ranchi University

Prolific Author of 50+ Books on AI, Machine Learning & Computer Science | 20+ Years Experience

Anshuman Kumar Mishra is a dedicated educator, researcher, and highly prolific author with over 20 years of experience in Computer Science and Information Technology. Holding an M.Tech in Computer Science from BIT Mesra, he brings a rare combination of academic depth and practical teaching expertise.

Currently serving as Assistant Professor at Doranda College under Ranchi University, he has mentored thousands of students, helping them build strong foundations in programming, data science, and artificial intelligence. His student-centric teaching style emphasizes conceptual clarity, hands-on practice, and real-world application.

Anshuman is a prolific author with more than 50 books published across a wide spectrum of computer science and emerging technology domains. From foundational programming languages to advanced topics in Artificial Intelligence, Machine Learning, Reinforcement Learning, Decision Theory, and Computer Vision — his books are widely appreciated by students, educators, and professionals for their clear explanations, strong theoretical foundation, and practical approach.

His extensive body of work reflects his deep commitment to making complex subjects accessible and meaningful for learners at all levels. He is particularly recognized for creating well-structured learning paths that help readers progress from beginner to advanced levels with confidence.

Driven by the mission to democratize quality technical education, Anshuman continues to write and update books that bridge the gap between academic theory and industry practice.

When not teaching or writing, he actively follows and explores new developments in AI, Quantum Machine Learning, and Ethical Intelligence systems.

Contents

Table of Contents

Table of Contents Chapter 1: The New Era of AI Engineering 7 1.1 From Traditional Software to AI-Powered Applications 7 1.2 Generative AI, Foundation Models and AI Engineering 9 1.3 LLMs, Multimodal Models and Reasoning Models 11 1.4 AI Application Architectures: Models, Data and Tools 13 1.5 Selecting an AI Use Case and Defining Success Metrics 15 Chapter 2: Large Language Models Under the Hood 25 2.1 Tokens, Context Windows and Model Outputs 25 2.2 Transformers and Attention: An Intuitive Introduction 28 2.3 Pretraining, Instruction Tuning and Fine-Tuning 30 2.4 Model Parameters, Latency and Inference Costs 32 2.5 Open-Weight Models versus Hosted Models 34 Engineering Checklist 38 Chapter Summary 39 Chapter 3: Building Reliable LLM Applications 42 3.1 Model APIs and Application Integration 42 3.2 Structured Outputs, JSON Schemas and Validation 45 3.3 Function Calling and Tool Integration 47 3.4 Conversation State and Context Management 49 3.5 Error Handling, Retries and Fallback Models 51 Reliability review questions 59 Chapter Summary 62 Chapter 4: Retrieval-Augmented Generation (RAG) 65 4.1 Why Language Models Need External Knowledge 66 4.2 Document Loading, Cleaning and Chunking 67 4.3 Embeddings and Semantic Search 70 4.4 Vector Databases and Metadata Filtering 71 4.5 Retrieval Strategies and Context Construction 73 Practical Lab 1: Build a small course-notes index 80 Practical Lab 2: Compare dense, lexical and hybrid retrieval 81 Chapter 5: Advanced RAG and Knowledge Systems 89 5.1 Query Routing and Multi-Stage Retrieval 89 5.2 Graph-Based Retrieval and Knowledge Graphs 91 5.3 Hybrid RAG with Structured and Unstructured Data 93 5.4 Handling Conflicting, Outdated and Missing Information 95 5.5 Citations, Source Attribution and Verifiable Answers 96 Integrated Case Study: A Verifiable University Knowledge Assistant 100 Table of Contents (continued) Practical Lab A: Build a Query Router 101 Chapter 6: Context Engineering for AI Applications 106 6.1 Context Windows versus Context Quality 106 6.2 Designing System Instructions and Task Context 108 6.3 Memory Selection, Summarisation and Retrieval 110 6.4 Context Compression and Long-Document Processing 112 6.5 Managing Tool Results and Intermediate Outputs 114 Integrated Case Study: University Knowledge Assistant 119 Practical Lab A: Design a Context Budget 119 Chapter 7: AI Agents and Agent Architectures 126 7.1 Chatbots, AI Assistants and Autonomous Agents 126 7.2 The Agent Loop: Observe, Decide, Act and Verify 126 7.3 Planning, Task Decomposition and Reasoning 126 7.4 Tool Selection and Controlled Tool Execution 126 7.5 Agent Memory and State Management 126 Chapter Review Questions 141 Multiple-Choice Questions 141 Chapter 8: Multi-Agent Systems 145 8.1 Single-Agent versus Multi-Agent Architectures 145 8.2 Coordinator, Supervisor and Specialist Agents 145 8.3 Agent Handoffs and Shared State 145 8.4 Communication Protocols and Task Delegation 145 8.5 Managing Loops, Conflicts and Failed Tasks 145 Chapter Review Questions 159 Multiple-Choice Questions 159 Chapter 9: Connecting Agents to Real-World Systems 163 9.1 Integrating APIs, Databases and External Services 163 9.2 Model Context Protocol (MCP) and Tool Connectivity 163 9.3 Workflow Orchestration and Event-Driven Execution 163 9.4 Authentication, Permissions and Least-Privilege Access 163 9.5 Scheduling, Background Jobs and Task Queues 163 Practical Lab: Design an Agent Integration 174 Chapter Review Questions 175 Chapter 10: Evaluating AI Systems 179 10.1 Why Traditional Software Testing Is Not Enough 179 10.2 Building Representative Test Datasets 180 10.3 Accuracy, Relevance, Groundedness and Completeness 182 Table of Contents (continued) 10.4 LLM-as-a-Judge: Benefits and Limitations 184 10.5 Testing Retrieval, Tool Calls and Agent Decisions 186 Practical Lab: Build a Small Evaluation Harness 191 Review Questions 192 Chapter 11: AI Security and Prompt Injection Defence 196 11.1 Direct and Indirect Prompt Injection 196 11.2 Data Leakage and Sensitive Information Protection 198 11.3 Insecure Tool Calls and Excessive Agent Permissions 201 11.4 Input Validation and Output Verification 203 11.5 Sandboxing, Approval Gates and Audit Trails 204 Practical Lab: Create a Prompt-Injection Defence Test Plan 210 Review Questions 211 Chapter 12: Responsible AI and Governance 216 12.1 Hallucinations, Bias and Uncertainty 216 12.2 Explainability and Human Oversight 219 12.3 Privacy, Consent and Data Governance 220 12.4 Copyright, Attribution and Intellectual Property 222 12.5 AI Risk Assessment and Documentation 223 12.5.6 Release readiness review 224 Practical Lab: Prepare a Responsible AI Governance Pack 227 Chapter 13: Deploying AI Applications 232 13.1 Application Architecture and Environment Configuration 234 13.2 Containers, Cloud Services and Deployment Basics 236 13.3 Authentication, Rate Limits and API Reliability 239 13.4 Caching, Batching and Latency Optimisation 241 13.5 Model Routing and Cost Management 244 Practical Lab: Deploy a Small AI API Safely 250 Review Questions 251 Chapter 14: Observability and LLMOps 255 14.0 The LLMOps feedback loop 256 14.1 Logging Inputs, Outputs and Tool Calls Safely 257 14.2 Distributed Tracing Across Agent Workflows 259 14.3 Monitoring Quality, Latency and Token Usage 261 14.4 Versioning Prompts, Models and Evaluation Datasets 263 Practical Lab: Instrument and Evaluate a Small LLM Workflow 269 Review Questions 270 Chapter 15: Fine-Tuning and Model Adaptation 276 Table of Contents (continued) 15.1 Prompt Engineering versus RAG versus Fine-Tuning 277 15.2 Preparing and Validating Training Data 279 15.3 Supervised Fine-Tuning Fundamentals 282 15.4 Parameter-Efficient Fine-Tuning and LoRA 284 15.5 Synthetic Data and Data Quality Risks 286 Practical Lab: Build an Adaptation Evaluation Plan 290 Review Questions 291 Chapter 16: AI for Business and Enterprise Workflows 296 16.1 Intelligent Document Processing 297 16.2 AI-Powered Research and Knowledge Assistants 300 16.3 Customer Support and Ticket Classification 297 16.4 Workflow Automation for Administrative Tasks 303 16.5 Data Analysis Assistants and Business Reporting 297 Integrated Case Study: Enterprise Operations Assistant 308 Practical Lab: Design a Bounded AI Workflow 309 Chapter 17: Multimodal AI Applications 317 17.1 Image Understanding and Visual Question Answering 318 17.2 Speech Recognition and Audio Understanding 318 17.3 Document Intelligence for PDFs and Scanned Pages 318 17.4 Video Summarisation and Temporal Information 318 17.5 Multimodal Retrieval and Search 318 Integrated Case Study: Multimodal Campus Information Assistant 328 Practical Lab: Build a Multimodal Search Prototype 329 Chapter 18: Building and Launching AI Products 337 18.1 Identifying a Real User Problem 338 18.2 Designing an AI Minimum Viable Product 338 18.3 Selecting Models, Tools and Infrastructure 338 18.4 Product Testing, User Feedback and Iteration 338 18.5 Deployment Readiness and Operational Checklists 338 Operational Readiness 346 Choosing a Portfolio Project 348

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub