Leanpub Header

Skip to main content

Material for Patterns of Application Development Using AI

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
About

About

About the Book

Price

Pick Your Price...

Minimum price

$19.00

$29.00

You pay

$29.00

Author earns

$23.20
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Obie Fernandez

The "one and only" Obie Fernandez is an avid writer and technology enthusiast, in addition to achieving worldwide success as an electronic music producer and touring DJ. He is a Principal Engineer at Shopify and boasts a legendary 30 year career in software development and entrepreneurship.

Obie has been CTO and co-founder of many startups including Mark Zuckerberg's beloved Andela and Trevor Owen's Lean Startup Machine. His published books include Patterns of Application Development Using AI many editions of The Rails Way and the acclaimed business title The Lean Enterprise. He also founded one of the world's best known Ruby on Rails web design and development agencies, Hashrocket and served for many years as the series editor for Addison-Wesley's Professional Ruby Series.

On the rare occasion when Obie is not busy building products, consulting clients or writing books, you can find him behind the lens of his camera or DJing in the dust at Burning Man.

Follow @obie on Twitter or email him at obiefernandez@gmail.com 

Leanpub Podcast

Episode 24

An Interview with Obie Fernandez

Contents

Table of Contents

1. Introduction

  1. Lesson Material
  2. Thoughts on Software Architecture
  3. What is a Large Language Model?
  4. Understanding Inference
  5. Large Language Models Come in Many Sizes and Flavors
  6. Retrieval vs Generative Models
  7. Retrieval-based Models
  8. Generative Models
  9. Hybrid Models
  10. Tokenization: Breaking Text into Pieces
  11. Context Size: How Much Information Can a Language Model Use During Inference?
  12. What is Context Size?
  13. Why is Context Size Important?
  14. Examples of Language Models with Different Context Sizes
  15. Choosing the Right Context Size
  16. Finding Needles in Haystacks
  17. Modalities: Beyond Text
  18. What are Modalities?
  19. Multimodal Language Models
  20. Benefits and Applications of Multimodal Models
  21. Provider Ecosystems
  22. OpenAI
  23. Anthropic
  24. Google
  25. Meta
  26. Cohere
  27. Ollama
  28. Multi-Model Platforms
  29. Choosing an LLM Provider
  30. OpenRouter
  31. Thinking About Performance
  32. Experimenting With Different LLM Models
  33. Compound AI Systems
  34. Deployment Patterns for Compound AI Systems
  35. Question and Answer
  36. Multi-Agent/Agentic Problem Solvers
  37. Conversational AI
  38. CoPilots
  39. Roles in Compound AI Systems
  40. Generator
  41. Retriever
  42. Ranker
  43. Classifier
  44. Tools & Agents
  45. Exercise
  46. Exercise 1
  47. Quiz
  48. Quiz 1
  49. Part I: Part 1: Fundamental Approaches & Techniques

2. Narrow The Path

  1. Lesson Material
  2. Latent Space: Incomprehensibly Vast
  3. How The Path Gets “Narrowed”
  4. Turning Down The Temperature
  5. Hyperparameters: Knobs and Dials of Inference
  6. Raw Versus Instruct-Tuned Models
  7. Raw Models: The Unfiltered Canvas
  8. Instruct-Tuned Models: The Guided Experience
  9. Choosing the Right Kind of Model for Your Project
  10. Prompt Engineering
  11. The Building Blocks of Effective Prompts
  12. The Art and Science of Prompt Design
  13. Prompt Engineering Techniques and Best Practices
  14. Zero-Shot Learning: When No Examples Are Needed
  15. One-Shot Learning: When a Single Example Can Make a Difference
  16. Few-Shot Learning: When Multiple Examples Can Improve Performance
  17. Example: Prompts Can Be Much More Complex Than You Imagine
  18. Experimentation and Iteration
  19. The Art of Vagueness
  20. Why Anthropomorphism Dominates Prompt Engineering
  21. Separating Instructions from Data: A Crucial Principle
  22. Prompt Distillation
  23. How It Works
  24. Initial Prompt Generation
  25. Prompt Refinement
  26. Prompt Compression
  27. System Directive and Context Integration
  28. Final Prompt Assembly
  29. Key Benefits
  30. What about fine-tuning?
  31. Exercise
  32. Exercise 2
  33. Quiz
  34. Quiz 2

3. Retrieval Augmented Generation (RAG)

  1. Lesson Material
  2. What is Retrieval Augmented Generation?
  3. How Does RAG Work?
  4. Why Use RAG in Your Applications?
  5. Implementing RAG in Your Application
  6. Preparation of Knowledge Sources (Chunking)
  7. Proposition Chunking
  8. Implementation Notes
  9. Quality Check
  10. Benefits of Proposition-Based Retrieval
  11. Real-World Examples of RAG
  12. Case Study: RAG in a Tax Preparation Application Without Embeddings
  13. Intelligent Query Optimization (IQO)
  14. Reranking
  15. RAG Assessment (RAGAs)
  16. Faithfulness
  17. Answer Relevance
  18. Context Precision
  19. Context Relevancy
  20. Context Recall
  21. Context Entities Recall
  22. Answer Semantic Similarity (ANSS)
  23. Answer Correctness
  24. Aspect Critique
  25. Challenges and Future Outlook
  26. Semantic Chunking: Enhancing Retrieval with Context-Aware Segmentation
  27. Hierarchical Indexing: Structuring Data for Improved Retrieval
  28. Self-RAG: A Self-Reflective Enhancement
  29. HyDE: Hypothetical Document Embeddings
  30. What is Contrastive Learning?
  31. Exercise
  32. Exercise 3
  33. Quiz
  34. Quiz 3

4. Multitude of Workers

  1. Lesson Material
  2. AI Workers As Independent Reusable Components
  3. Account Management
  4. E-commerce Applications
  5. Product Recommendations
  6. Fraud Detection
  7. Customer Sentiment Analysis
  8. Healthcare Applications
  9. Patient Intake
  10. Patient Risk Assessment
  11. AI Worker as a Process Manager
  12. Store Your Trigger Messages
  13. Integrating AI Workers Into Your Application Architecture
  14. Designing Clear Interfaces and Communication Protocols
  15. Handling Data Flow and Synchronization
  16. Managing the Lifecycle of AI Workers
  17. Composability and Orchestration of AI Workers
  18. Chaining AI Workers for Multi-Step Workflows
  19. Parallel Processing for Independent AI Workers
  20. Ensemble Techniques for Improved Accuracy
  21. Dynamic Selection and Invocation of AI Workers
  22. Combining Traditional NLP with LLMs
  23. Exercise
  24. Exercise 4
  25. Quiz
  26. Quiz 4

5. Tool Use

  1. Lesson Material
  2. What is Tool Use?
  3. The Potential of Tool Use
  4. The Tool Use Workflow
  5. Include function definitions in your request context
  6. Dynamic Tool Selection
  7. Forced (aka Explicit) Tool Selection
  8. Tool Choice Parameter
  9. Forcing a Function To Get Structured Output
  10. Execution of Function(s)
  11. Optional Continuation of the Original Prompt
  12. Best Practices for Tool Use
  13. Descriptive Definitions
  14. Processing of Tool Results
  15. Error Handling
  16. Iterative Refinement
  17. Composing and Chaining Tools
  18. Future Directions
  19. Exercise
  20. Exercise 5
  21. Quiz
  22. Quiz 5

6. Stream Processing

  1. Lesson Material
  2. Implementating a ReplyStream
  3. The “Conversation Loop”
  4. Auto Continuation
  5. Conclusion
  6. Exercise
  7. Exercise 6
  8. Quiz
  9. Quiz 6

7. Self Healing Data

  1. Lesson Material
  2. Practical Case Study: Fixing Broken JSON
  3. Considerations and Counterindications
  4. Data Criticality
  5. Error Severity
  6. Domain Complexity
  7. Explainability and Transparency
  8. Unintended Consequences
  9. Exercise
  10. Exercise 7
  11. Quiz
  12. Quiz 7

8. Contextual Content Generation

  1. Lesson Material
  2. Personalization
  3. Productivity
  4. Rapid Iteration and Experimentation
  5. Scalability and Efficiency
  6. AI Powered Localization
  7. The Importance of User Testing and Feedback
  8. Exercise
  9. Exercise 8
  10. Quiz
  11. Quiz 8

9. Generative UI

  1. Lesson Material
  2. Generating Copy for User Interfaces
  3. Personalized Forms
  4. Contextual Field Suggestions
  5. Adaptive Field Ordering
  6. Personalized Microcopy
  7. Personalized Validation
  8. Progressive Disclosure
  9. Context-Aware Explanatory Text
  10. Defining Generative UI
  11. Example
  12. The Shift to Outcome-Oriented Design
  13. Challenges and Considerations
  14. Future Outlook and Opportunities
  15. Exercise
  16. Exercise 9
  17. Quiz
  18. Quiz 9

10. Intelligent Workflow Orchestration

  1. Lesson Material
  2. Business Need
  3. Key Benefits
  4. Key Patterns
  5. Dynamic Task Routing
  6. Contextual Decision Making
  7. Adaptive Workflow Composition
  8. Exception Handling and Recovery
  9. Implementing Intelligent Workflow Orchestration in Practice
  10. Intelligent Order Processor
  11. Intelligent Content Moderator
  12. Predictive Task Scheduling in a Customer Support System
  13. Exception Handling and Recovery in a Data Processing Pipeline
  14. Monitoring and Logging
  15. Monitoring Workflow Progress and Performance
  16. Logging Key Events and Decisions
  17. Benefits of Monitoring and Logging
  18. Considerations and Best Practices
  19. Scalability and Performance Considerations
  20. Handling High Volumes of Concurrent Workflows
  21. Optimizing Performance of AI-Powered Components
  22. Monitoring and Profiling Performance
  23. Scaling Strategies
  24. Performance Optimization Techniques
  25. Testing and Validation of Workflows
  26. Unit Testing Workflow Components
  27. Integration Testing Workflow Interactions
  28. Testing AI Decision Points
  29. End-to-End Testing
  30. Continuous Integration and Deployment
  31. Exercise
  32. Exercise 10
  33. Quiz
  34. Quiz 10
  35. Part II: Part 2: The Patterns

11. Prompt Engineering

  1. Lesson Material
  2. Chain of Thought
  3. How It Works
  4. Examples
  5. Content Generation
  6. Structured Entity Creation
  7. LLM Agent Guidance
  8. Benefits and Considerations
  9. Mode Switch
  10. How It Works
  11. When to Use It
  12. Example
  13. Role Assignment
  14. How It Works
  15. When to Use It
  16. Examples
  17. Prompt Object
  18. How It Works
  19. Prompt Template
  20. How It Works
  21. Benefits and Considerations
  22. When to Use It:
  23. Example
  24. Structured IO
  25. How It Works
  26. Scaling Structured IO
  27. Benefits and Considerations
  28. Prompt Chaining
  29. How It Works
  30. When To Use It
  31. Example: Olympia’s Onboarding
  32. Prompt Rewriter
  33. How It Works
  34. Example
  35. Response Fencing
  36. How It Works
  37. Benefits and Considerations
  38. Error Handling
  39. Query Analyzer
  40. How It Works
  41. Implementation
  42. Part-of-Speech (POS) Tagging and Named Entity Recognition (NER)
  43. Intent Classification
  44. Keyword Extraction
  45. Benefits
  46. Query Rewriter
  47. How It Works
  48. Example
  49. Benefits
  50. Ventriloquist
  51. How It Works
  52. When to Use It
  53. Example
  54. Exercise
  55. Exercise 11
  56. Quiz
  57. Quiz 11

12. Discrete Components

  1. Lesson Material
  2. Predicate
  3. How It Works
  4. When to Use It
  5. Example
  6. API Facade
  7. How It Works
  8. Key Benefits
  9. When To Use It
  10. Example
  11. Authentication and Authorization
  12. Request Handling
  13. Response Formatting
  14. Error Handling and Edge Cases
  15. Scalability and Performance Considerations
  16. Comparison with Other Design Patterns
  17. Result Interpreter
  18. How It Works
  19. When to Use It
  20. Example
  21. Virtual Machine
  22. How It Works
  23. When to Use It
  24. Example
  25. Behind The Magic
  26. Specification and Testing
  27. Specifying the Behavior
  28. Writing Test Cases
  29. Example: Testing the Translator Component
  30. Replay of HTTP Interactions
  31. Exercise
  32. Exercise 12
  33. Quiz
  34. Quiz 12

13. Human In The Loop (HITL)

  1. Lesson Material
  2. High-Level Patterns
  3. Hybrid Intelligence
  4. Adaptive Response
  5. Human-AI Role Switching
  6. Escalation
  7. How It Works
  8. Key Benefits
  9. Real-World Application: Healthcare
  10. Feedback Loop
  11. How It Works
  12. Applications and Examples
  13. Advanced Techniques in Human Feedback Integration
  14. Passive Information Radiation
  15. How It Works
  16. Contextual Information Display
  17. Proactive Notifications
  18. Explanatory Insights
  19. Interactive Exploration
  20. Key Benefits
  21. Applications and Examples
  22. Collaborative Decision Making (CDM)
  23. How It Works
  24. Example
  25. Continuous Learning
  26. How It Works
  27. Applications and Examples
  28. Example
  29. Ethical Considerations
  30. Role of HITL in Mitigating AI Risks
  31. Technological Advancements and Future Outlook
  32. Challenges and Limitations of HITL Systems
  33. Exercise
  34. Exercise 13
  35. Quiz
  36. Quiz 13

14. Intelligent Error Handling

  1. Lesson Material
  2. Traditional Error Handling Approaches
  3. Contextual Error Diagnosis
  4. How It Works
  5. Prompt Engineering for Contextual Error Diagnosis
  6. Retrieval-Augmented Generation for Contextual Error Diagnosis
  7. Intelligent Error Reporting
  8. Predictive Error Prevention
  9. How It Works
  10. Smart Error Recovery
  11. How It Works
  12. Personalized Error Communication
  13. How It Works
  14. Adaptive Error Handling Workflow
  15. How It Works
  16. Exercise
  17. Exercise 14
  18. Quiz
  19. Quiz 14

15. Quality Control

  1. Lesson Material
  2. Eval
  3. Problem
  4. Solution
  5. How It Works
  6. Example
  7. Considerations
  8. Understanding Golden References
  9. How Reference-Free Evals Work
  10. Guardrail
  11. Problem
  12. Solution
  13. How It Works
  14. Example
  15. Considerations
  16. Guardrails and Evals: Two Sides of the Same Coin
  17. The Interchangeability of Guardrails and Reference-Free Evals
  18. Implementing Dual-Purpose Guardrails and Evals
  19. Exercise
  20. Exercise 15
  21. Quiz
  22. Quiz 15
  23. Part III: Glossary
  24. A
  25. B
  26. C
  27. D
  28. E
  29. F
  30. G
  31. H
  32. Inference
  33. J
  34. K
  35. L
  36. M
  37. N
  38. O
  39. P
  40. Q
  41. R
  42. S
  43. T
  44. U
  45. V
  46. W
  47. Z

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

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.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

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.)

In fact, authors have earned over $14 million writing, publishing and selling 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