Jump to ratings and reviews
Rate this book

Generative AI with LangChain: Build large language model (LLM) apps with Python, ChatGPT, and other LLMs

Rate this book
Get to grips with the LangChain framework to develop production-ready applications, including agents and personal assistants, integrating with web searches and code execution. Purchase of the print or Kindle book includes a free PDF eBook The ChatGPT and the GPT models by OpenAI have brought about a revolution in the way we think about the world ― and not only in how we write and research, but in how we can process information. This book discusses the functioning, capabilities, and limitations of LLMs including ChatGPT and Bard. It also demonstrates how to use the LangChain framework to implement production-ready applications based on these models, such as agents and personal assistants, and integrate with other tools such as web searches and code execution. As you progress through the chapters, you’ll use transformer models and diverse attention mechanisms, refining the intricate process of training and fine-tuning. You'll get to grips with data-driven decision-making with automated analysis and visualization using pandas and Python. You’ll also take a closer look at the heuristics of how to use these models, prompting, training and fine-tuning, and deploying at scale. By the time you’ve finished this book, you’ll have a deep understanding of what makes LLMs tick and how to make the most of them. The book is for developers, researchers, and anyone interested in learning more about LLMs. Written in a clear and concise style, this book includes plenty of code examples to help readers learn with practise. Whether you are a beginner or an experienced developer, this book will be a valuable resource for anyone who wants to get the most out of LLMs and is 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.

376 pages, Paperback

Published December 22, 2023

14 people are currently reading
49 people want to read

About the author

Ben Auffarth

7 books6 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
6 (19%)
4 stars
11 (35%)
3 stars
11 (35%)
2 stars
1 (3%)
1 star
2 (6%)
Displaying 1 - 4 of 4 reviews
Profile Image for Barack Liu.
586 reviews19 followers
January 14, 2024

502-Build large language model (LLM) apps with Python, ChatGPT, and other LLMs-Ben Auffarth - LLM-2023

Barack
2024/01/14

"Build large language model (LLM) apps with Python, ChatGPT, and other LLMs", first published in 2023. This book discusses the operation, capabilities, and limitations of LLM (including ChatGPT and Bard). It also demonstrates how the LangChain framework can be used to implement production-ready applications based on these models (such as agents and personal assistants) and integrate with other tools (such as web search and code execution). As the chapters progress, you will refine the complex training and fine-tuning process using Transformer models and different attention mechanisms. You'll master data-driven decision-making through automated analysis and visualization using pandas and Python. You'll also take a closer look at how to use these models, tips, training and fine-tuning, and heuristics for large-scale deployment.

Ben Auffarth lives in Hammersmith, England, United Kingdom. Studied at New Bulgarian University, Orta Do ğ u Teknik Ü niversitesi / Middle East Technical University,
Chuo University , Universität Osnabrück, Universitat de Barcelona, KTH Royal Institute of Technology. Worked at Universitat de Barcelona, Institute for Bioengineering of Catalonia (IBEC),
KTH, Freie Universität Berlin , Foundation for Research and Technology - Hellas (FORTH),
Data scientist/ programmer, Oleeo, loveholidays, Hastings Direct.

Table of Contents
Chapter 1: What Is Generative AI?
Chapter 2: LangChain for LLM Apps
Chapter 3: Getting Started with LangChain
Chapter 4: Building Capable Assistants
Chapter 5: Building a Chatbot like ChatGPT
Chapter 6: Developing Software with Generative AI
Chapter 7: LLMs for Data Science
Chapter 8: Customizing LLMs and Their Output
Chapter 9: Generative AI in Production
Chapter 10: The Future of Generative Models

In 2023, many people in the technology industry believe that this is a milestone year in the history of AI development and even in the history of technology as a whole. One of the most influential products this year is undoubtedly ChatGPT-3 and ChatGPT -4. Although there have been other versions of GPT before it, it was ChatGPT-3 that came out of the circle and attracted widespread attention from the whole society. ChatGPT-3 adopts the widely recognized general transformer algorithm-General Transformer AI. The characteristic of this algorithm is to generate new content based on existing content, rather than just analyzing and organizing existing content, which is different from the traditional analysis model. From its name - Generative Pre-trained Transformer - we can see that it is a pre-trained generative model and is universal. The core technology of this model is based on the Large Language Model, and its core concept is to use a statistical-based natural language processing method supported by a large amount of data. Through deep learning methods and large-scale data training, the high-level models we see now are formed, with parameter scales reaching hundreds of billions. From my undergraduate studies to now, the first time I was deeply impressed by AI was when AlphaGo defeated Lee Sedol in March 2016. Although AlphaGo caused a huge sensation in the industry at that time, it was the first time I felt the power of AI. At that time, I was not sensitive enough to realize its far-reaching significance. Now, with the emergence of ChatGPT-3, this is the second time that I have become deeply concerned about AI. As the saying goes, "There are only three things that can be done", I have only now gradually developed enough interest in this field.

Large Language Models (LLMs) are nothing new, they have been around in technology for some time. However, the GPT series, especially GPT-3, has become an outstanding representative in this field and attracted widespread attention. The most notable feature of the GPT series is the huge increase in the number of parameters. For example, the number of parameters of GPT-2 is about one billion, while the parameters of GPT-3 have increased to one hundred billion, and GPT-4 has reached one trillion. Processing such a huge number of parameters requires massive resource support, and there must be a strong company behind it. Just like building an aircraft carrier, it requires the support of a powerful country. OpenAI, the company that launched the GPT series, was founded in 2015 and was originally a non-profit organization. In 2019, it began to transform into a profit-making organization and received strong support from Microsoft in the same year. Without Microsoft's investment of resources, OpenAI may not be able to reach the heights it is today. Likewise, if OpenAI had chosen other partners, its trajectory might have been very different. The significant rise in Microsoft's stock price since the beginning of 2023 partly reflects the success of this decision. In this era of rapid development, even a technology giant like Microsoft can experience huge ups and downs within a year, just like riding a roller coaster. For practitioners in the technology industry, this means that they cannot relax at all and can only constantly pursue progress.

The core of the language model is to predict the next part of the content based on the context. This part of the content may be a word, a sentence, or even a paragraph. It is based on Natural Language Processing (NLP) and relies on Representation Learning. The so-called "representation learning" refers to performing machine learning tasks based on the understanding of the intrinsic characteristics of the original data, rather than relying on manual specification of specific characteristics. For example, in image recognition, representation learning enables the model to autonomously select features such as edges, shapes, textures, etc. to distinguish different images, rather than having these features directly specified by engineers. In fact, the core of discussing the capabilities of language models lies in the understanding of "capabilities". So, what is "ability"? We can draw an analogy from the human learning process. Humans first acquire contextual information or pre-knowledge (usually verified knowledge learned in textbooks), and then make judgments and applications based on this knowledge. In the process of applying knowledge, different people may use different judgment standards. The “ability” here refers to the ability to extract and apply information from existing knowledge, which plays a vital role in both humans and language models.

GPT-1 first came out in 2018, but it was not until GPT-3 in 2022 that it really entered the public eye. Looking back on 2018, I realize that I knew almost nothing about the birth of GPT-1 at that time. On the one hand, this is because ChatGPT was still in the early stages of development at that time, and society did not pay enough attention to it; on the other hand, it also reflects my lack of sufficient knowledge of the most cutting-edge developments in the technical field, whether in academia or industry. sensitivity. Even in the field of blockchain that I studied before, or in the field of computer graphics that I am currently studying, I lack enough sensitivity to cutting-edge developments. We should always ask ourselves: How much do I know about the history of this field? Am I aware of the latest technological advances? What insights do I have about possible future developments in this field? Machine learning is a hot topic right now, just as it was in 2016 when AlphaGo burst onto the public scene. Of course, not everyone has to do Machine learning or Deep Learning, even if you choose, does not mean that everyone should do algorithms and models. It is also very important to use the powerful tools available to do something valuable and meaningful. Just like the rapid development of the mobile Internet in the past few years, not only mobile phone manufacturers and mobile application stores have gained huge opportunities, but companies that use smartphones to innovate in different segments have also gained many opportunities. Similarly, the rise of the World Wide Web in the 1990s not only brought opportunities to companies selling computers and browsers but also emerging industries that used the Internet to develop, such as e-commerce, also gained huge development opportunities. This also applies to the field of AI. We don’t necessarily have to be engineers or researchers to directly build or improve AI technology, but we can find innovative ways of using it in different industries and fields by understanding and applying these technologies. Just as mobile phones and the Internet have changed every aspect of our lives, AI and machine learning will also open new doors of opportunity in the future. The way to salvation, or in it.

Recently, I have been looking for a full-time job after graduation, and I also see many classmates sharing their resumes in the alumni group and seeking internal recommendations from alumni. As a student majoring in computer science, I noticed that the research and project experiences of many students in the same major are mostly related to machine learning, which is obviously keeping up with the current technology hotspots. This triggered some thoughts on my career choices: How many people study machine learning out of personal interest, and how many people do it because they see its future development prospects? When considering personal career development, we need to weigh multiple factors, but how should the weight be distributed among these factors? Especially when it comes to the main influencing factors, what should we use as a reference? For example, if one is not interested in the low-level details of machine learning, should one still pursue the hot topics in this field? As life stages change, decision-making seems to become increasingly complex. When we're young, our decisions are largely based on personal preference, and as we get older, we may be more inclined to make the "right" choice than the one we really want. When we are young, our decision-making mistakes may be protected by our families and schools, but as time goes by, when we face life independently, we basically have to be responsible for our own decisions, and the impact of these decisions will become greater and greater.

In the past ten years or so, the computer field has experienced many hot changes, including mobile Internet, cloud computing, artificial intelligence, virtual reality/augmented reality (VR/AR), blockchain, and blockchain-based Web 3.0. Whenever we look back at these technology waves, we will find that each era has its obvious mainstream trends, and the cycles of these trends may only be a few years or even a few months. This trend is occurring significantly more frequently than in the past. On the positive side, this means there are more opportunities, as adventurers are always attracted to unexplored lands. However, from a negative perspective, the rapid development of technology also means that if you are not careful, you may be left behind by the times. When I was studying in Shanghai, my research direction was blockchain. Looking back a few years later, I found that my previous knowledge base was out of touch with current hot topics. Although today's technology still builds on the foundations of the past, a sense of disconnect remains. There will definitely be more new technologies emerging in the future. In this context, how should individuals stabilize their core competitiveness? Perhaps, we need to find our truest interests and return to those original intentions that are not affected by the outside world. For example, if my motivation comes from storytelling, then AI can be used to help me tell better stories, VR/AR can be used to enhance the presentation of the story, and other technologies may also play an important role in this process. The key is that we need to always remember that technology is a tool, not an end.

In the field of chatbots, the evolution from quantitative change to qualitative change is significant. In fact, ChatGPT is not the first chatbot. As early as 2014, Microsoft launched the XiaoIce chatbot. However, at that time, XiaoIce was more of an entertainment chat tool. Compared with the current GPT series, the impression left by the XiaoIce series in the public mind is not that significant. An important reason why the GPT series can successfully "break out of the circle" is that they provide truly useful information, which is not limited to smooth conversations, but can also be applied to learning and work. In the development of large-scale language models, we can see an obvious process from quantitative change to qualitative change. From GPT-1 to GPT-2, then to GPT-3, and now GPT-4, the number of parameters used in model training has increased by orders of magnitude each time, and each improvement has significantly optimized the performance of the model. Although I believe that this growth will eventually enter a plateau like the S curve, at least for now, it seems that it is far from reaching this stage and is still growing linearly or even exponentially.

Displaying 1 - 4 of 4 reviews

Can't find what you're looking for?

Get help and learn more about the design.