Quick Start Guide to Large Language Models: Strategies and Best Practices for ChatGPT, Embeddings, Fine-Tuning, and Multimodal AI, 2nd Edition

Book description

The Practical, Step-by-Step Guide to Using LLMs at Scale in Projects and Products

Large Language Models (LLMs) like Llama 3, Claude 3, and the GPT family are demonstrating breathtaking capabilities, but their size and complexity have deterred many practitioners from applying them. In Quick Start Guide to Large Language Models, Second Edition, pioneering data scientist and AI entrepreneur Sinan Ozdemir clears away those obstacles and provides a guide to working with, integrating, and deploying LLMs to solve practical problems.

Ozdemir brings together all you need to get started, even if you have no direct experience with LLMs: step-by-step instructions, best practices, real-world case studies, and hands-on exercises. Along the way, he shares insights into LLMs' inner workings to help you optimize model choice, data formats, prompting, fine-tuning, performance, and much more. The resources on the companion website include sample datasets and up-to-date code for working with open- and closed-source LLMs such as those from OpenAI (GPT-4 and GPT-3.5), Google (BERT, T5, and Gemini), X (Grok), Anthropic (the Claude family), Cohere (the Command family), and Meta (BART and the LLaMA family).

  • Learn key concepts: pre-training, transfer learning, fine-tuning, attention, embeddings, tokenization, and more

  • Use APIs and Python to fine-tune and customize LLMs for your requirements

  • Build a complete neural/semantic information retrieval system and attach to conversational LLMs for building retrieval-augmented generation (RAG) chatbots and AI Agents

  • Master advanced prompt engineering techniques like output structuring, chain-of-thought prompting, and semantic few-shot prompting

  • Customize LLM embeddings to build a complete recommendation engine from scratch with user data that outperforms out-of-the-box embeddings from OpenAI

  • Construct and fine-tune multimodal Transformer architectures from scratch using open-source LLMs and large visual datasets

  • Align LLMs using Reinforcement Learning from Human and AI Feedback (RLHF/RLAIF) to build conversational agents from open models like Llama 3 and FLAN-T5

  • Deploy prompts and custom fine-tuned LLMs to the cloud with scalability and evaluation pipelines in mind

  • Diagnose and optimize LLMs for speed, memory, and performance with quantization, probing, benchmarking, and evaluation frameworks

"A refreshing and inspiring resource. Jam-packed with practical guidance and clear explanations that leave you smarter about this incredible new field."

--Pete Huang, author of The Neuron

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. About This eBook
  3. Title Page
  4. Copyright Page
  5. Contents
  6. Foreword
  7. Preface
    1. Audience and Prerequisites
    2. How to Approach This Book
    3. Overview
    4. Unique Features
    5. Summary
  8. Acknowledgments
  9. About the Author
  10. Part I: Introduction to Large Language Models
    1. 1. Overview of Large Language Models
      1. What Are Large Language Models?
      2. Popular Modern LLMs
      3. Applications of LLMs
      4. Summary
    2. 2. Semantic Search with LLMs
      1. Introduction
      2. The Task
      3. Solution Overview
      4. The Components
      5. Putting It All Together
      6. The Cost of Closed-Source Components
      7. Summary
    3. 3. First Steps with Prompt Engineering
      1. Introduction
      2. Prompt Engineering
      3. Working with Prompts Across Models
      4. Summary
    4. 4. The AI Ecosystem: Putting the Pieces Together
      1. Introduction
      2. The Ever-Shifting Performance of Closed-Source AI
      3. AI Reasoning versus Thinking
      4. Case Study 1: Retrieval Augmented Generation
      5. Case Study 2: Automated AI Agents
      6. Conclusion
  11. Part II: Getting the Most Out of LLMs
    1. 5. Optimizing LLMs with Customized Fine-Tuning
      1. Introduction
      2. Transfer Learning and Fine-Tuning: A Primer
      3. A Look at the OpenAI Fine-Tuning API
      4. Preparing Custom Examples with the OpenAI CLI
      5. Setting Up the OpenAI CLI
      6. Our First Fine-Tuned LLM
      7. Summary
    2. 6. Advanced Prompt Engineering
      1. Introduction
      2. Prompt Injection Attacks
      3. Input/Output Validation
      4. Batch Prompting
      5. Prompt Chaining
      6. Case Study: How Good at Math Is AI?
      7. Summary
    3. 7. Customizing Embeddings and Model Architectures
      1. Introduction
      2. Case Study: Building a Recommendation System
      3. Summary
    4. 8. AI Alignment: First Principles
      1. Introduction
      2. Aligned to Whom and to What End?
      3. Alignment as a Bias Mitigator
      4. The Pillars of Alignment
      5. Constitutional AI: A Step Toward Self-Alignment
      6. Conclusion
  12. Part III: Advanced LLM Usage
    1. 9. Moving Beyond Foundation Models
      1. Introduction
      2. Case Study: Visual Q/A
      3. Case Study: Reinforcement Learning from Feedback
      4. Summary
    2. 10. Advanced Open-Source LLM Fine-Tuning
      1. Introduction
      2. Example: Anime Genre Multilabel Classification with BERT
      3. Example: LaTeX Generation with GPT2
      4. Sinan’s Attempt at Wise Yet Engaging Responses: SAWYER
      5. Summary
    3. 11. Moving LLMs into Production
      1. Introduction
      2. Deploying Closed-Source LLMs to Production
      3. Deploying Open-Source LLMs to Production
      4. Summary
    4. 12. Evaluating LLMs
      1. Introduction
      2. Evaluating Generative Tasks
      3. Evaluating Understanding Tasks
      4. Conclusion
      5. Keep Going!
  13. Part IV: Appendices
    1. A. LLM FAQs
      1. The LLM already knows about the domain I’m working in. Why should I add any few-shot examples or grounded content as in RAG?
      2. I just want to deploy a closed-source API. What are the main things I need to look out for?
      3. I really want to deploy an open-source model. What are the main things I need to look out for?
      4. Creating and fine-tuning my own model architecture seems hard. What can I do to make it easier?
      5. I think my model is susceptible to prompt injections or going off task. How do I correct it?
      6. Why didn’t we talk about third-party LLM tools like LangChain?
      7. How do I deal with overfitting or underfitting in LLMs?
      8. How can I use LLMs for non-English languages? Are there any unique challenges?
      9. How can I implement real-time monitoring or logging to understand the performance of my deployed LLM better?
      10. What are some things we didn’t talk about in this book?
    2. B. LLM Glossary
      1. Transformer Architecture
      2. Attention Mechanism
      3. Large Language Model (LLM)
      4. Autoregressive Language Models
      5. Autoencoding Language Models
      6. Transfer Learning
      7. Prompt Engineering
      8. Alignment
      9. Reinforcement Learning from Human Feedback (RLHF)
      10. Reinforcement Learning from AI Feedback (RLAIF)
      11. Corpora
      12. Fine-Tuning
      13. Labeled Data
      14. Hyperparameters
      15. Learning Rate
      16. Batch Size
      17. Training Epochs
      18. Evaluation Metrics
      19. Incremental/Online Learning
      20. Overfitting
      21. Underfitting
      22. Knowledge Distillation
      23. Task-Specific Distillation
      24. Task-Agnostic Distillation
      25. Multimodal Models
      26. Alignment
    3. C. LLM Application Archetypes
      1. General Chatbots / Retrieval Augmented Generation (RAG)
      2. Agents
      3. Fine-Tuning a Closed-Source LLM
      4. Fine-Tuning an Open-Source LLM
      5. Fine-Tuning a Bi-encoder to Learn New Embeddings
      6. Fine-Tuning an LLM for Following Instructions Using Both LM Training and Reinforcement Learning from Human / AI Feedback (RLHF and RLAIF)
      7. Open-Book Question-Answering
      8. Visual Question-Answering
  14. Index
  15. Credits
  16. Code Snippets

Product information

  • Title: Quick Start Guide to Large Language Models: Strategies and Best Practices for ChatGPT, Embeddings, Fine-Tuning, and Multimodal AI, 2nd Edition
  • Author(s): Sinan Ozdemir
  • Release date: October 2024
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780135346570