Until launch dayOctober 20 Our new book, AI Engineering For Production, launches October 20.New book: AI Engineering For Production, October 20. Join us on launch day
Academy
Our Courses Mentorship About Us B2B Affiliate Contact Sign in
Join the Mentorship Enroll now
Towards AI Academy · From our book

Our Building LLMs for Production Ebook

Enhancing LLM Abilities and Reliability with Prompting, Fine-Tuning, and RAG.

With all future updates · 10,000+ copies sold · 84 lessons, taught as a course
Building LLMs for Production book and course art
01Inside the book

What's inside this 470-page book (Updated October 2024)?

Please note: this e-book is an interactive resource, not a downloadable PDF.

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

Industry leaders on the book

“This is the most comprehensive textbook to date on building LLM applications, and helps learners understand everything from fundamentals to the simple-to-advanced building blocks of constructing LLM applications. The application topics include prompting, RAG, agents, fine-tuning, and deployment - all essential topics in an AI Engineer's toolkit.”

Jerry Liu
Jerry Liu
Co-founder and CEO, LlamaIndex

“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
Pete Huang
Co-founder, The Neuron

“An indispensable guide for anyone venturing into the world of large language models…Covering everything from theory to practical deployment, it’s a must-have in the library of every aspiring and seasoned AI professional.”

Shashank Kalanithi
Shashank Kalanithi
Data Engineer, Meta

“It contains thorough explanations and code for you to start using and deploying LLMs, as well as optimizing their performance. Very highly recommended!”

Luis Serrano
Luis Serrano, PhD
Founder, Serrano.Academy · author, Grokking Machine Learning

“It covers the foundational aspects of LLMs as well as advanced use-cases like finetuning LLMs, Retrieval Augmented Generation and Agents. This will be valuable to anyone looking to dive into the field quickly and efficiently.”

Jeremy Pinto
Jeremy Pinto
Senior Applied Research Scientist, Mila
03Chapter overview

Every chapter, tutorial by tutorial

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

Who is it for?

01AI Practitioners & Programmers Tinkerers
02AI/ML Engineers & Computer Science Professionals
03Students/Researchers & Job Seekers
05Reader reviews

What our readers say

I'm learning lots

The concepts are clearly explained, and the sample code really helps reinforce the material. I now need to develop a project and put this all together.

Mark Chase

Well worth a read

If you have aspirations to dive into the world of generative artificial intelligence (GenAI) and large language models (LLMs), you could definitely do worse than starting with this book. As the title implies, it is focused on building and thus relatively light on theory. It teaches you what you need to know behind the scenes but not much more than that. For instance, there is almost no math. The tutorials and code samples are the highlight of the book, as they exemplify how the literature is actually put into practice. As with any field, the more knowledge you already possess coming into this book, the less value you will find in reading it. However, everyone should find something worthwhile. One area of this book I feel could really be improved upon is the section on deployment. Running a GenAI app locally on your laptop is a very different game from running it in production in terms of scalability. An app that runs smoothly for ten users will incur previously unseen issues when deployed for ten thousand and will incur even more issues for ten million. Scaling, debugging and troubleshooting in production deserve more attention than is given in this book for it to maximize its value for professional AI engineers. Overall, it is well worth a thorough reading and should prove to be of aid to your career if you wish to step into this field.

Frederick Zhang

A Practical Guide to Building LLMs

"Building LLMs for Production" is an invaluable guide for anyone looking to deploy large language models efficiently and effectively. What sets this book apart is its all-in-one approach, covering everything from model architecture and optimization to scaling and deployment—all in a clear, accessible format that both beginners and experts can appreciate. The authors take a truly user-centric perspective, ensuring that practical implementation remains front and center. Whether you're integrating LLMs into existing workflows or building from scratch, this book simplifies complex concepts while maintaining technical depth. For developers and AI practitioners looking for a comprehensive, no-fluff resource, "Building LLMs for Production" is the go-to playbook for modern AI deployment. Highly recommended!"

Brian Langrin

A very good read on Large language models

I am super excited to recommend this book to everyone. Written in a very excellent manner and covering all the essential details and concepts in the world of large language models. The complex and difficult concepts are easily graspable and the text is fully focused and coherent. Highly recommended book for academia as well as industry people.

Jamshaid Sohail

Outstanding Book useful for both LLM Industry, academic and private projects

I recently read Building LLMs for Production: Enhancing LLM Abilities and Reliability with Prompting, Fine-Tuning, and RAG, and I couldn’t be more satisfied with the insights and practical knowledge it provided. As someone involved in building robust AI-driven solutions, I found this book incredibly useful. It breaks down complex concepts like prompting strategies, fine-tuning techniques, and Retrieval-Augmented Generation (RAG) into manageable, actionable steps. The explanations are clear, and the examples are practical and relevant to real-world applications. This book is a must-have for anyone looking to take their LLMs from experimental stages to reliable, production-ready tools. Highly recommended!

James Odendal

Best one that accumulates all knowledge

Abhijit L

Top-notch book for getting into building LLM apps

If you are interested in building AI apps, this book serves as a fantastic icebreaker, being one of the few within the AI space worth your time and money.

Paul Iusztin

excelent book highly recommended

nice balance between intuitive explanations and code

Roberto Pardo

Excellent course for beginners and Experienced persons

This is an excellent book and I would like to recommend this book to everyone. I was having little idea about how to build an application and plan for production deployment but after going through this book , I came across the various techniques to take into account to develop application and its deployment aspects. This book is worth every penny.

Vinay Gupta

Simply a must-read

The second version of this book can easily be considered a must-read as well as the first version. It's great to have key and evolving concepts explained like this!

Eugenio Galioto

Best book on the topic

The GO-TO guy about AI and LLM

Hiroto Matsushima

Brilliant book

Covers every aspect of a broad range of topics.

soumen nayak

Comprehensive Coverage and Practical

The book has great coverage of nearly all the important topics related to LLMs and application-building with LLMs. I also liked the focus on the hands-on projects, so that you are not just reading but also trying things out.

Priyankar Kumar

The Only AI Engineering Toolkit You Need!

To build scalable and reliable products with LLMs

Get Your Copy Now!
06The full stack

Everything the book covers

Building LLMs for Production intro video poster

LLM Fundamentals, Architecture, & LLMs in Practice

  • Building blocks of LLMslanguage modeling, tokenization, embeddings, emergent abilities, scaling laws, context size…
  • Transformer Architectureattention mechanism, design choices, encoder-only, decoder-only and encoder-decoder transformers, GPT Architecture, Masked Self-Attention, MinGPT
  • Hallucinations & Biasesmitigation strategies, controlling LLM outputs
  • Decoding methodsgreedy search, sampling, beam search, top-k sampling, top-p sampling
  • Objective functions and evaluation metricsperplexity metric and GLUE, SuperGLUE, BIG-Bench, HELM, FLASK Benchmarks…

Prompting & Frameworks

  • Prompting techniqueszero-shot, in context, few-shot, role, chains, and chain-of-thought…
  • SecurityPrompt Injection and Prompt Hacking
  • LangChainprompt templates, output parsers, summarization chain, QA chains
  • LlamaIndexvector stores, embeddings, data connectors, nodes, indexes

RAG & Fine-Tuning

  • Data IngestionPDFs, web pages, Google Drive, text splitters, LangChain Chains
  • EmbeddingsVector Stores with Activeloop's Deep Lake
  • Querying in LlamaIndexquery construction, expansion, transformation, splitting, customizing a retriever engine…
  • Reranking Documentsrecursive, small-to-big
  • RAG MetricsMean Reciprocal Rank (MRR), Hit Rate, Mean Average Precision (MAP), and Normalized Discounted Cumulative Gain (NDCG)…
  • Evaluation Toolsevaluating with ragas, custom evaluation of RAG pipelines
  • Fine-Tuning Optimization TechniquesLoRA, QLoRA, supervised fine-tuning, SFT RLHF

Agents, Optimization & Deployment

  • AgentsUsing AutoGPT & BabyAGI with LangChain
  • Agent Simulation ProjectsCAMEL, Generative Agents
  • Building AgentsLangGPT, OpenAI Assistants
  • Optimization & Deploymentchallenges, quantization, pruning, distillation, cloud deployment, CPU and GPU optimization & deployment, creating APIs from open-source LLMs
07Why this book

Why should you read this book?

Future-Proof Skills

This book explores various methods to adapt "foundational" LLMs to specific tasks with enhanced accuracy, reliability, and scalability. It tackles the lack of reliability of "out of the box" LLMs by teaching the AI developer tech stack of the future; Prompting, Fine-Tuning, RAG, and Tools Use.

Scalable Solutions

The book aims to guide developers through creating LLM products ready for production, leveraging the potential of AI across various industries. It breaks down techniques that are scalable for enterprise-level workflows, helping both independent developers and small companies with limited resources create AI products that deliver value to paying customers.

Practical Expertise for Everyone

The book is for anyone who wants to build LLM products that can serve real use cases today. It comes with access to our webpage where we also share lots of additional up-to-date content, code, notebooks, and resources. However, the coding parts of the book is tailored for readers with an intermediate knowledge of Python.

08Questions

FAQ

What skills do I learn?
The book is packed with theories, concepts, projects, applications, and experience that you can confidently put on your CVs. You can add these skills straight into your resume: Large Language Models (LLMs) | LangChain | LlamaIndex | Vector databases | RAG | Prompting | Fine-tuning | Agents | Deployment & Deployment Optimizations | Creating chatbots | Chat with PDFs | Summarization | AI Assistants | RLHF
What are the prerequisites to read the book?
The book is written for readers without prior knowledge of AI or NLP. It introduces topics from the ground up, aiming to help you feel comfortable using the power of AI in your next project or to elevate your current project to the next level. A basic understanding of Python helps comprehend the code and implementations, while advanced use cases of the coding techniques are explained in detail in the course.
How do we make sure the book is not outdated?
We ensure the book remains relevant by focusing on the core principles of building production products with LLMs, which are foundational and transferable across generations of models. While the field is fast-evolving and new techniques will emerge, today's LLM developer stack will still be crucial for adapting future models to specific industries and data. Additionally, we provide access to an up-to-date webpage with extra content, code, notebooks, and resources, ensuring readers stay current with the latest advancements.
Does it come with a physical copy?
No. This e-book version is hosted on the platform (not a pdf). You can purchase a soft or hard copy of the book on Amazon. If you have a physical copy, email Louis-François at louis@towardsai.net, and we'd be happy to give you a discount on the e-book!
Do you have a referral or affiliate program?
If you refer three or more people, we’ll send you a physical copy of our book as a thank you! Additionally, we have an affiliate program for individuals with an audience. By joining, you can earn commissions for every successful referral made through your unique affiliate link. Please email Louis-François at louis@towardsai.net with proof of referral.
Can I take this course within my company?
Yes! We offer both course bundles and custom training solutions tailored specifically for companies. For more information on company packages or to discuss a customized training plan, reach out to Louis at louis@towardsai.net.