Generative AI with LangChain

Book description

Get to grips with the LangChain framework from theory to deployment and develop production-ready applications. Code examples regularly updated on GitHub to keep you abreast of the latest LangChain developments. Purchase of the print or Kindle book includes a free PDF eBook.

Key Features

  • Learn how to leverage LLMs’ capabilities and work around their inherent weaknesses
  • Delve into the realm of LLMs with LangChain and go on an in-depth exploration of their fundamentals, ethical dimensions, and application challenges
  • Get better at using ChatGPT and GPT models, from heuristics and training to scalable deployment, empowering you to transform ideas into reality

Book Description

ChatGPT and the GPT models by OpenAI have brought about a revolution not only in how we write and research but also in how we can process information. This book discusses the functioning, capabilities, and limitations of LLMs underlying chat systems, including ChatGPT and Bard. It also demonstrates, in a series of practical examples, how to use the LangChain framework to build production-ready and responsive LLM applications for tasks ranging from customer support to software development assistance and data analysis – illustrating the expansive utility of LLMs in real-world applications.

Unlock the full potential of LLMs within your projects as you navigate through guidance on fine-tuning, prompt engineering, and best practices for deployment and monitoring in production environments. Whether you're building creative writing tools, developing sophisticated chatbots, or crafting cutting-edge software development aids, this book will be your roadmap to mastering the transformative power of generative AI with confidence and creativity.

What you will learn

  • Understand LLMs, their strengths and limitations
  • Grasp generative AI fundamentals and industry trends
  • Create LLM apps with LangChain like question-answering systems and chatbots
  • Understand transformer models and attention mechanisms
  • Automate data analysis and visualization using pandas and Python
  • Grasp prompt engineering to improve performance
  • Fine-tune LLMs and get to know the tools to unleash their power
  • Deploy LLMs as a service with LangChain and apply evaluation strategies
  • Privately interact with documents using open-source LLMs to prevent data leaks

Who this book is for

The book is for developers, researchers, and anyone interested in learning more about LLMs. Whether you are a beginner or an experienced developer, this book will serve as a valuable resource if you want to get the most out of LLMs and are looking to stay ahead of the curve in the LLMs and LangChain arena. Basic knowledge of Python is a prerequisite, while some prior exposure to machine learning will help you follow along more easily.

Table of contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Get in touch
  2. What Is Generative AI?
    1. Introducing generative AI
      1. What are generative models?
      2. Why now?
    2. Understanding LLMs
      1. What is a GPT?
      2. Other LLMs
      3. Major players
      4. How do GPT models work?
        1. Pre-training
        2. Tokenization
        3. Scaling
        4. Conditioning
      5. How to try out these models
    3. What are text-to-image models?
    4. What can AI do in other domains?
    5. Summary
    6. Questions
    7. Join our community on Discord
  3. LangChain for LLM Apps
    1. Going beyond stochastic parrots
      1. What are the limitations of LLMs?
      2. How can we mitigate LLM limitations?
      3. What is an LLM app?
    2. What is LangChain?
    3. Exploring key components of LangChain
      1. What are chains?
      2. What are agents?
      3. What is memory?
      4. What are tools?
    4. How does LangChain work?
    5. Comparing LangChain with other frameworks
    6. Summary
    7. Questions
    8. Join our community on Discord
  4. Getting Started with LangChain
    1. How to set up the dependencies for this book
      1. pip
      2. Poetry
      3. Conda
      4. Docker
    2. Exploring API model integrations
      1. Fake LLM
      2. OpenAI
      3. Hugging Face
      4. Google Cloud Platform
      5. Jina AI
      6. Replicate
      7. Others
        1. Azure
        2. Anthropic
    3. Exploring local models
      1. Hugging Face Transformers
      2. llama.cpp
      3. GPT4All
    4. Building an application for customer service
    5. Summary
    6. Questions
    7. Join our community on Discord
  5. Building Capable Assistants
    1. Mitigating hallucinations through fact-checking
    2. Summarizing information
      1. Basic prompting
      2. Prompt templates
      3. Chain of density
      4. Map-Reduce pipelines
      5. Monitoring token usage
    3. Extracting information from documents
    4. Answering questions with tools
      1. Information retrieval with tools
      2. Building a visual interface
    5. Exploring reasoning strategies
    6. Summary
    7. Questions
    8. Join our community on Discord
  6. Building a Chatbot like ChatGPT
    1. What is a chatbot?
    2. Understanding retrieval and vectors
      1. Embeddings
      2. Vector storage
        1. Vector indexing
        2. Vector libraries
        3. Vector databases
    3. Loading and retrieving in LangChain
      1. Document loaders
      2. Retrievers in LangChain
        1. kNN retriever
        2. PubMed retriever
        3. Custom retrievers
    4. Implementing a chatbot
      1. Document loader
      2. Vector storage
      3. Memory
        1. Conversation buffers
        2. Remembering conversation summaries
        3. Storing knowledge graphs
        4. Combining several memory mechanisms
        5. Long-term persistence
    5. Moderating responses
    6. Summary
    7. Questions
    8. Join our community on Discord
  7. Developing Software with Generative AI
    1. Software development and AI
      1. Code LLMs
    2. Writing code with LLMs
      1. StarCoder
      2. StarChat
      3. Llama 2
      4. Small local model
    3. Automating software development
    4. Summary
    5. Questions
    6. Join our community on Discord
  8. LLMs for Data Science
    1. The impact of generative models on data science
    2. Automated data science
      1. Data collection
      2. Visualization and EDA
      3. Preprocessing and feature extraction
      4. AutoML
    3. Using agents to answer data science questions
    4. Data exploration with LLMs
    5. Summary
    6. Questions
    7. Join our community on Discord
  9. Customizing LLMs and Their Output
    1. Conditioning LLMs
      1. Methods for conditioning
        1. Reinforcement learning with human feedback
        2. Low-rank adaptation
        3. Inference-time conditioning
    2. Fine-tuning
      1. Setup for fine-tuning
      2. Open-source models
      3. Commercial models
    3. Prompt engineering
      1. Prompt techniques
        1. Zero-shot prompting
        2. Few-shot learning
        3. Chain-of-thought prompting
        4. Self-consistency
        5. Tree-of-thought
    4. Summary
    5. Questions
    6. Join our community on Discord
  10. Generative AI in Production
    1. How to get LLM apps ready for production
      1. Terminology
    2. How to evaluate LLM apps
      1. Comparing two outputs
      2. Comparing against criteria
      3. String and semantic comparisons
      4. Running evaluations against datasets
    3. How to deploy LLM apps
      1. FastAPI web server
      2. Ray
    4. How to observe LLM apps
      1. Tracking responses
      2. Observability tools
      3. LangSmith
      4. PromptWatch
    5. Summary
    6. Questions
    7. Join our community on Discord
  11. The Future of Generative Models
    1. The current state of generative AI
      1. Challenges
      2. Trends in model development
      3. Big Tech vs. small enterprises
      4. Artificial General Intelligence
    2. Economic consequences
      1. Creative industries and advertising
      2. Education
      3. Law
      4. Manufacturing
      5. Medicine
      6. Military
    3. Societal implications
      1. Misinformation and cybersecurity
      2. Regulations and implementation challenges
    4. The road ahead
    5. Join our community on Discord
    6. Why subscribe?
  12. Other Books You May Enjoy
  13. Index

Product information

  • Title: Generative AI with LangChain
  • Author(s): Ben Auffarth
  • Release date: December 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781835083468