Building LLMs for Production

Book description

“This is the most comprehensive textbook to date on building LLM applications - all essential topics in an AI Engineer's toolkit."
- Jerry Liu, Co-founder and CEO of LlamaIndex

TL;DR
With amazing feedback from industry leaders, this book is an end-to-end resource for anyone looking to enhance their skills or dive into the world of AI and develop their understanding of Generative AI and Large Language Models (LLMs). It explores various methods to adapt "foundational" LLMs to specific use cases with enhanced accuracy, reliability, and scalability. Written by over 10 people on our Team at Towards AI and curated by experts from Activeloop, LlamaIndex, Mila, and more, it is a roadmap to the tech stack of the future.

The book aims to guide developers through creating LLM products ready for production, leveraging the potential of AI across various industries. It is tailored for readers with an intermediate knowledge of Python.

What's Inside this 470-page Book (Updated October 2024)?

Hands-on Guide on LLMs, Prompting, Retrieval Augmented Generation (RAG) & Fine-tuning
Roadmap for Building Production-Ready Applications using LLMs
Fundamentals of LLM Theory
Simple-to-Advanced LLM Techniques & Frameworks
Code Projects with Real-World Applications
Colab Notebooks that you can run right away
Community access and our own AI Tutor

Table of Contents

Chapter I Introduction to Large Language Models
Chapter II LLM Architectures & Landscape
Chapter III LLMs in Practice
Chapter IV Introduction to Prompting
Chapter V Retrieval-Augmented Generation
Chapter VI Introduction to LangChain & LlamaIndex
Chapter VII Prompting with LangChain
Chapter VIII Indexes, Retrievers, and Data Preparation
Chapter IX Advanced RAG
Chapter X Agents
Chapter XI Fine-Tuning
Chapter XII Deployment and Optimization

What Experts Think About The Book

"A truly wonderful resource that develops understanding of LLMs from the ground up, from theory to code and modern frameworks. Grounds your knowledge in research trends and frameworks that develop your intuition around what's coming. Highly recommend."
- Pete Huang, Co-founder of The Neuron

“This book is filled with end-to-end explanations, examples, and comprehensive details. Louis and the Towards AI team have written an essential read for developers who want to expand their AI expertise and apply it to real-world challenges, making it a valuable addition to both personal and professional libraries.”
- Alex Volkov, AI Evangelist at Weights & Biases and Host of ThursdAI news

"This book is the most thorough overview of LLMs I've come across. An excellent primer for newcomers and a valuable reference for experienced practitioners."
- Shaw Talebi, Founder of The Data Entrepreneurs, AI Educator and Advisor

Whether you're looking to enhance your skills or dive into the world of AI for the first time as a programmer or software student, our book is for you. From the basics of LLMs to mastering fine-tuning and RAG for scalable, reliable AI applications, we guide you every step of the way.

Table of contents

  1. What Experts Think About Building LLMs for Production
  2. Table of Contents
  3. Acknowledgment
  4. Preface
  5. Introduction
    1. Why Prompt Engineering, Fine-Tuning, and RAG?
    2. Coding Environment and Packages
  6. Chapter I: Introduction to LLMs
    1. A Brief History of Language Models
    2. What are Large Language Models?
    3. Building Blocks of LLMs
    4. Tutorial: Translation with LLMs (GPT-3.5 API)
    5. Tutorial: Control LLMs Output with Few-Shot Learning
    6. Recap
  7. Chapter II: LLM Architectures and Landscape
    1. Understanding Transformers
    2. Transformer Model’s Design Choices
    3. Transformer Architecture Optimization Techniques
    4. The Generative Pre-trained Transformer (GPT) Architecture
    5. Introduction to Large Multimodal Models
    6. Proprietary vs. Open Models vs. Open-Source Language Models
    7. Applications and Use-Cases of LLMs
    8. Recap
  8. Chapter III: LLMs in Practice
    1. Understanding Hallucinations and Bias
    2. Reducing Hallucinations by Controlling LLM Outputs
    3. Evaluating LLM Performance
    4. Recap
  9. Chapter IV: Introduction to Prompting
    1. Prompting and Prompt Engineering
    2. Prompting Techniques
    3. Prompt Injection and Security
    4. Recap
  10. Chapter V: Retrieval-Augmented Generation
    1. Why RAG?
    2. Building a Basic RAG Pipeline from Scratch
    3. Recap
  11. Chapter VI: Introduction to LangChain & LlamaIndex
    1. LLM Frameworks
    2. LangChain Introduction
    3. Tutorial 1: Building LLM-Powered Applications with LangChain
    4. Tutorial 2: Building a News Articles Summarizer
    5. LlamaIndex Introduction
    6. LangChain vs. LlamaIndex vs. OpenAI Assistants
    7. Recap
  12. Chapter VII: Prompting with LangChain
    1. What are LangChain Prompt Templates
    2. Few-Shot Prompts and Example Selectors
    3. What are LangChain Chains
    4. Tutorial 1: Managing Outputs with Output Parsers
    5. Tutorial 2: Improving Our News Articles Summarizer
    6. Tutorial 3: Creating Knowledge Graphs from Textual Data: Finding Hidden Connections
    7. Recap
  13. Chapter VIII: Indexes, Retrievers, and Data Preparation
    1. LangChain’s Indexes and Retrievers
    2. Data Ingestion
    3. Text Splitters
    4. Similarity Search and Vector Embeddings
    5. Tutorial 1: A Customer Support Q&A Chatbot
    6. Tutorial 2: A YouTube Video Summarizer Using Whisper and LangChain
    7. Tutorial 3: A Voice Assistant for Your Knowledge Base
    8. Tutorial 4: Preventing Undesirable Outputs with the Self-Critique Chain
    9. Tutorial 5: Preventing Undesirable Outputs from a Customer Service Chatbot
    10. Recap
  14. Chapter IX: Advanced RAG
    1. From Proof of Concept to Product: Challenges of RAG Systems
    2. Advanced RAG Techniques with LlamaIndex
    3. RAG - Metrics & Evaluation
    4. LangChain LangSmith and LangChain Hub
    5. Recap
  15. Chapter X: Agents
    1. What are Agents: Large Models as Reasoning Engines
    2. An Overview of AutoGPT and BabyAGI
    3. The Agent Simulation Projects in LangChain
    4. Tutorial 1: Building Agents for Analysis Report Creation
    5. Tutorial 2: Query and Summarize a DB with LlamaIndex
    6. Tutorial 3: Building Agents with OpenAI Assistants
    7. Tutorial 4: LangChain OpenGPT
    8. Tutorial 5: Multimodal Financial Document Analysis from PDFs
    9. Recap
  16. Chapter XI: Fine-Tuning
    1. Understanding Fine-Tuning
    2. Low-Rank Adaptation (LoRA)
    3. Tutorial 1: SFT with LoRA
    4. Tutorial 2: Using SFT and LoRA for Financial Sentiment
    5. Tutorial 3: Fine-Tuning a Cohere LLM with Medical Data
    6. Reinforcement Learning from Human Feedback
    7. Tutorial 4: Improving LLMs with RLHF
    8. Recap
  17. Chapter XII: Deployment and Optimization
    1. Model Distillation and Teacher-Student Models
    2. LLM Deployment Optimization: Quantization, Pruning, and Speculative Decoding
    3. Tutorial: Deploying a Quantized LLM on a CPU on Google Cloud Platform (GCP)
    4. Deploying Open-Source LLMs on Cloud Providers
    5. Recap
  18. Conclusion
  19. Further Reading and Courses

Product information

  • Title: Building LLMs for Production
  • Author(s): Louis-Francois Bouchard, Louie Peters
  • Release date: October 2024
  • Publisher(s): Towards AI
  • ISBN: 9798324731472