LangChain in your Pocket

Book description

Learn about LangChain and LLMs with "LangChain in your Pocket," a comprehensive guide to leveraging this innovative framework for building language-based applications.

Key Features

  • Step-by-step code explanations with expected outputs for each solution
  • Practical examples and hands-on tutorials for real-world application
  • Detailed discussions on managing and evaluating large language models

Book Description

"LangChain in your Pocket" offers a detailed exploration into the LangChain framework, designed to enhance your skills in developing sophisticated language understanding models and applications. This book begins with the basics, introducing you to the fundamental concepts of LangChain through a simple "Hello World" example. As you progress, you'll delve into various LangChain modules, learning how to create agents, manage memory, and utilize output parsers effectively.

The journey continues as you explore the RAG Framework, vector databases, and their applications in natural language processing, providing you with the tools to tackle common NLP problems efficiently. The book also addresses critical aspects of working with large language models (LLMs), such as prompt engineering, handling hallucinations, and evaluating model outputs. Advanced topics like autonomous AI agents and the integration of LangSmith and LangServe are covered, giving you a holistic view of what you can achieve with LangChain.

By the end of this book, you will not only understand the technical aspects of LangChain but also how to apply these principles in real-world scenarios, making it an essential resource for anyone looking to advance their capabilities in AI and language processing.

What you will learn

  • Navigate the basic to advanced features of LangChain
  • Build and manage language understanding models and applications
  • Employ advanced prompt engineering techniques
  • Implement and evaluate large language models effectively
  • Develop autonomous AI agents with LangChain
  • Integrate LangSmith and LangServe for enhanced functionality

Who this book is for

The book "LangChain in your Pocket: Beginner's Guide to Building Generative AI Applications using LLMs" is an excellent resource for individuals new to the world of Generative AI. Whether you are a software developer, data scientist, or student, this beginner-friendly book provides a comprehensive introduction to the LangChain framework and its practical applications. Regardless of your prior experience, this book is a valuable asset for anyone interested in diving into the world of Generative AI and leveraging the power of LangChain.

Table of contents

  1. Copyright
  2. Preface
  3. Chapter 1: Introduction
    1. 1.1 What are LLMs?
    2. 1.2 Different LLM families
    3. 1.3 What is LangChain used for?
    4. 1.4 Why LangChain?
    5. 1.5 Book Overview
  4. Chapter 2: Hello World
    1. 2.1 Setting up LangChain
    2. 2.2 Name Generator
    3. 2.3 Text Pre-processing
    4. 2.4 Storyteller
    5. 2.5 LangChain using Local LLMs
  5. Chapter 3: Different LangChain Modules
  6. Chapter 4: Models and Prompts
    1. 4.1 Models
      1. 4.1.1 LLM
      2. 4.1.2 ChatModel
    2. 4.2 Prompts
      1. 4.2.1 PromptTemplate
      2. 4.2.2 ChatPromptTemplate
  7. Chapter 5: Chains
    1. 5.1 LLMChain
    2. 5.2 Auto-SQL Chain
    3. 5.3 MathsChain
    4. 5.4 DALL-E using LLMChain
    5. 5.5 Custom Chains using LCEL
    6. 5.6 Types of Chains
  8. Chapter 6: Agents
    1. 6.1 How are Agents different from Chains?
    2. 6.2 Building Agents using LangChain
    3. 6.3 Types of Agents
    4. 6.4 Custom Tools for Agents
  9. Chapter 7: OutputParsers and Memory
    1. 7.1 OutputParsers
      1. 7.1.1 CommaSeparatedListOutputParser
      2. 7.1.2 Custom OutputParser
      3. 7.1.3 Magic Output Fixer
    2. 7.2 Memory
      1. 7.2.1 ConversationalBufferMemory
      2. 7.2.2 ConversationSummaryMemory
  10. Chapter 8: Callbacks
    1. 8.1 What are Callbacks?
    2. 8.2 StdOutputCallbackHandler
    3. 8.3 FileHandler
    4. 8.4 Custom Callbacks
  11. Chapter 9: RAG Framework and Vector Databases
    1. 9.1 What is RAG?
    2. 9.2 Different components of RAG
    3. 9.3 RAG using LangChain
    4. 9.4 Multi-document RAG
    5. 9.5 Recommendation System using RAG
    6. 9.6 Vector Databases
  12. Chapter 10: LangChain for NLP problems
    1. 10.1 Summarization
    2. 10.2 Text Tagging and Classification
    3. 10.3 Named Entity Recognition
    4. 10.4 Text Embeddings
    5. 10.5 Few-Shot Classification
      1. 10.5.1 What is Few-Shot Learning?
      2. 10.5.2 Multi-Classification
      3. 10.5.3 Example Selection
    6. 10.6 POS Tagging, Segmentation and more
  13. Chapter 11: Handling LLM Hallucinations
    1. 11.1 What are Hallucinations?
    2. 11.2 Why do LLMs Hallucinate?
    3. 11.3 LLMCheckerChain
    4. 11.4 LLMSummarizationChain
    5. 11.5 Avoiding Hallucinations using RAG
  14. Chapter 12: Evaluating LLMs
    1. 12.1 String Evaluators
      1. 12.1.1 Criteria Evaluators
      2. 12.1.2 Custom Evaluators
    2. 12.2 Comparison Evaluators
    3. 12.3 Trajectory Evaluators
  15. Chapter 13: Advanced Prompt Engineering
    1. 13.1 Chain of Thoughts
      1. 13.1.1 Think Step by Step
      2. 13.1.2 Few-Shot Prompting
    2. 13.2 ReAct
    3. 13.3 Tree of Thoughts
    4. 13.4 Other Prompt Engineering Techniques
  16. Chapter 14: Autonomous AI agents
    1. 14.1 What is AGI?
    2. 14.2 AutoGPT
    3. 14.3 BabyAGI
    4. 14.4 HuggingGPT
  17. Chapter 15: LangSmith and LangServe
    1. 15.1 LangSmith
    2. 15.2 LangServe
  18. Chapter 16: Additional Features
    1. 16.1 Fallbacks
      1. 16.1.1 Fallback for LLMs
      2. 16.1.2 Fallback for Chains
    2. 16.2 Safety
      1. 16.2.1 OpenAIModerationChain
      2. 16.2.2 ConstitutionalChain
    3. 16.3 Model Laboratory
    4. 16.4 Debugging and Verbose
  19. Endnotes
  20. About the Author

Product information

  • Title: LangChain in your Pocket
  • Author(s): Mehul Gupta
  • Release date: May 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781836201250