Skip to content

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.

License

Notifications You must be signed in to change notification settings

benman1/generative_ai_with_langchain

Repository files navigation

Generative AI with LangChain, 2024 Edition

This is the code repository for Generative AI with LangChain, 2024 Edition, published by Packt.

Build large language model (LLM) apps with Python, ChatGPT, and other LLMs

Ben Auffarth

      Free PDF       Amazon      

About the book

Generative AI with LangChain, 2024 Edition

Large Language Models (LLMs) like GPT-4o, Gemini, Claude and others 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, and how to build applications with generative AI, especially LLMs. 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.

Key Learnings

  • 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

Note to Readers

Thank you for choosing "Generative AI with LangChain"! We appreciate your enthusiasm and feedback.

Please note that we've released an updated version of the book. Consequently, there are two different branches for this repository:

  • main - this is the original version of the book.
  • softupdate - this is for the latest update of the book, corresponding to ver 0.1.13 of LangChain.

Please refer to the version that you are interested in or that corresponds to your version of the book.

Download a free PDF Coding

Download a free PDF Coding

If you have already purchased an up-to-date print or Kindle version of this book, you can get a DRM-free PDF version at no cost. Simply click on the link to claim your free PDF. Free-Ebook Coding

We also provide a PDF file that has color images of the screenshots/diagrams used in this book at GraphicBundle Coding

Commitment

Code Updates: Our commitment is to provide you with stable and valuable code examples. While LangChain is known for frequent updates, we understand the importance of aligning our code with the latest changes. The companion repository is regularly updated to harmonize with LangChain developments.

Expect Stability: For stability and usability, the repository might not match every minor LangChain update. We aim for consistency and reliability to ensure a seamless experience for our readers.

How to Reach Us: Encountering issues or have suggestions? Please don't hesitate to open an issue, and we'll promptly address it. Your feedback is invaluable, and we're here to support you in your journey with LangChain. Thank you for your understanding and happy coding!

Know more on the Discord server Coding

You can engage with the author and other readers on the discord server and find latest updates and discussions in the community at Discord

Chapters

In the following table, you can find links to the directories in this repository. Each directory contains further links to python scripts and to notebooks. You can also see links to computing platforms, where you can execute the notebooks in the repository. Please note that there are other Python scripts and projects that are not notebooks, which you'll find in the chapter directories.

Chapters Colab Kaggle Gradient Studio Lab
Chapter 1: What Is Generative AI? no code examples
Chapter 2: LangChain for LLM Apps no code examples
Chapter 3: Getting Started with LangChain directory
  • LLMs_chat_models_and_prompts.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • Running_local_models.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • customer_service_helper.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • customer_service_use_case.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • hf_hub_models.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • map-reduce.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • tracking_costs.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • wolfram_alpha.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
Chapter 4: Building Capable Assistants directory
  • information_extraction.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • mitigating_hallucinations.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • tool_use.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
Chapter 5: Building a Chatbot like ChatGPT directory
  • embeddings.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • memory.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • moderation.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • pdf_summary.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • retrievers.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
Chapter 6: Developing Software with Generative AI directory
  • code_models.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • code_understanding.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • langchain_rag.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
  • software_development.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
Chapter 7: LLMs for Data Science directory
  • data_science.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
Chapter 8: Customizing LLMs and Their Output directory
  • fine_tuning.ipynb
Open In Colab
Open In Kaggle
Open In Gradient
Open In Studio Lab
Chapter 9: Generative AI in Production directory
Chapter 10: The Future of Generative Models no code examples

Requirements for this book

Software and hardware list

This is the companion repository for the book. Here are a few instructions that help getting set up. Please also see chapter 3.

All chapters rely on Python.

Chapter Software required Link to the software Hardware specifications OS required
All chapters Python 3.11 https://www.python.org/downloads/ Should work on any recent computer Windows, MacOS, Linux (any), macOS, Windows

Please note that Python 3.12 might not work (see #11).

Please check the instructions for setting up the environment either in the book or here. They include instructions for dependencies and API keys. Following the instructions should make sure that you don't have any issues running the code in the book or this repository. If you encounter any issues, please make sure you've followed these instructions.

👋 Contribute

We welcome contributions from developers of all levels. If you'd like to contribute, please check our contributing guidelines and help make this repository and the book more accessible.


Star History Chart

❤️ Contributors

repo contributors

Get to know the authors

Ben Auffarth Ben Auffarth is a full-stack data scientist with more than 15 years of work experience. With a background and Ph.D. in computational and cognitive neuroscience, he has designed and conducted wet lab experiments on cell cultures, analyzed experiments with terabytes of data, run brain models on IBM supercomputers with up to 64k cores, built production systems processing hundreds and thousands of transactions per day, and trained language models on a large corpus of text documents. He co-founded and is the former president of Data Science Speakers, London.

About

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published