1 00:00:00,760 --> 00:00:04,590 This first lecture will be an introduction to LangChain. 2 00:00:05,060 --> 00:00:09,150 You'll learn what it is, its use cases, and its components. 3 00:00:09,760 --> 00:00:13,210 After this theoretical lecture, we'll move on to coding. 4 00:00:14,420 --> 00:00:15,490 What is LangChain? 5 00:00:16,140 --> 00:00:18,390 LangChain is an open -source framework 6 00:00:18,400 --> 00:00:25,470 that allows developers working with AI to combine large language models or LLMs 7 00:00:25,480 --> 00:00:30,650 like GPT -4 with external sources of computation and data. 8 00:00:31,740 --> 00:00:37,610 The framework is currently offered as a Python or a JavaScript package and is 9 00:00:37,620 --> 00:00:39,170 under heavy development. 10 00:00:40,520 --> 00:00:43,830 It is used to build complete apps using 11 00:00:43,840 --> 00:00:45,450 LLMs very quickly. 12 00:00:46,660 --> 00:00:50,810 Using LLMs is often insufficient for 13 00:00:50,820 --> 00:00:52,710 creating truly powerful apps. 14 00:00:53,800 --> 00:00:57,270 This is because LLMs are often limited in 15 00:00:57,280 --> 00:01:03,690 their ability to understand the context, interact with the real world, or learn 16 00:01:03,700 --> 00:01:04,610 and adapt. 17 00:01:05,700 --> 00:01:09,310 To understand what needs LangChain fills, 18 00:01:09,960 --> 00:01:11,750 let's look at a practical example. 19 00:01:12,860 --> 00:01:16,890 We all know that LLMs, such as ChatGPT 20 00:01:16,900 --> 00:01:19,790 and GPT -4, have an impressive general knowledge. 21 00:01:20,280 --> 00:01:23,230 We can ask them about almost anything and 22 00:01:23,240 --> 00:01:24,370 get a pretty good answer. 23 00:01:24,940 --> 00:01:26,650 But what if you want to know something 24 00:01:26,660 --> 00:01:30,470 specific from your own data, your own documents? 25 00:01:31,120 --> 00:01:33,870 It could be a book, a PDF file, or a 26 00:01:33,880 --> 00:01:36,450 database with proprietary information. 27 00:01:37,600 --> 00:01:40,290 LangChain allows you to connect a large 28 00:01:40,300 --> 00:01:44,890 language model like GPT -4 to your own sources of data. 29 00:01:46,380 --> 00:01:49,070 This is what data -aware means. 30 00:01:49,680 --> 00:01:51,810 And LangChain is data -aware. 31 00:01:52,900 --> 00:01:58,550 Of course, you can give the information to the AI model as input into the prompt. 32 00:01:58,900 --> 00:02:00,630 But I'm talking about something else. 33 00:02:00,640 --> 00:02:02,970 I'm talking about referencing an entire 34 00:02:02,980 --> 00:02:05,970 database field with your own data. 35 00:02:07,580 --> 00:02:11,010 Using LangChain, you can make GPT -4 work 36 00:02:11,020 --> 00:02:16,370 with your own data, and it can also take the action you'd like. 37 00:02:17,500 --> 00:02:24,270 For instance, search the web, fill out a form, or send an email with some specific information. 38 00:02:25,480 --> 00:02:27,930 This is what agentic -aware means. 39 00:02:28,940 --> 00:02:33,330 So, LangChain is data -aware and agentic -aware. 40 00:02:34,440 --> 00:02:38,810 The example I've described to you works like this. 41 00:02:39,700 --> 00:02:44,950 You take the document you want your language model to reference and slice it 42 00:02:44,960 --> 00:02:46,830 up into smaller chunks. 43 00:02:47,780 --> 00:02:50,710 Store those chunks in a vector database 44 00:02:50,720 --> 00:02:55,630 as embeddings, which are numeric representations of the text. 45 00:02:55,640 --> 00:03:02,730 In fact, these capabilities open up an infinite number of practical use cases. 46 00:03:03,240 --> 00:03:04,890 Just imagine the possibilities. 47 00:03:05,440 --> 00:03:07,870 You can have a large language model that 48 00:03:07,880 --> 00:03:12,170 references the Constitution or the Civil Code of your own country. 49 00:03:12,480 --> 00:03:17,770 You can ask the application anything about the Constitution or the laws you 50 00:03:17,780 --> 00:03:18,710 are interested in. 51 00:03:19,040 --> 00:03:21,210 And the application will give you the 52 00:03:21,220 --> 00:03:21,870 correct answer. 53 00:03:22,300 --> 00:03:25,310 It's like having a specialized lawyer in 54 00:03:25,320 --> 00:03:28,950 front of you that can be asked anything for free. 55 00:03:29,440 --> 00:03:32,210 This will open up a world of new opportunities. 56 00:03:33,180 --> 00:03:35,310 I believe we are going to see exponential 57 00:03:35,320 --> 00:03:38,990 progress in data analytics and data science. 58 00:03:39,680 --> 00:03:41,970 Our ability to connect large language 59 00:03:41,980 --> 00:03:47,590 models to advanced APIs is really going to take things to the next level. 60 00:03:48,600 --> 00:03:55,050 LangChain implements abstractions like chains and agents so that a developer 61 00:03:55,060 --> 00:03:57,990 doesn't have to know what happens under the hood. 62 00:03:58,740 --> 00:04:05,390 Let's go over some specific examples of applications that can be created using LangChain. 63 00:04:06,020 --> 00:04:10,870 Chatbots – question -answering systems or summarization tools. 64 00:04:11,720 --> 00:04:17,570 LangChain can be used to create chatbots that can interact with users in a natural way. 65 00:04:17,940 --> 00:04:22,670 For example, you could use LangChain to create a chatbot that can answer customer 66 00:04:22,680 --> 00:04:28,630 questions or provide support based on the internal documentation of the company. 67 00:04:29,460 --> 00:04:34,390 LangChain can be used to create question -answering systems that can answer 68 00:04:34,400 --> 00:04:37,790 questions in a comprehensive and informative way. 69 00:04:37,800 --> 00:04:42,370 For example, you could use LangChain to create a question -answering system that 70 00:04:42,380 --> 00:04:48,050 can answer questions about a particular product, service, or topic such as 71 00:04:48,060 --> 00:04:50,790 history, science, or current events. 72 00:04:51,780 --> 00:04:53,710 LangChain can be used to create 73 00:04:53,720 --> 00:04:59,250 summarization tools that can summarize long pieces of text in a concise and 74 00:04:59,260 --> 00:05:00,190 informative way. 75 00:05:00,660 --> 00:05:03,090 For example, you could use LangChain to 76 00:05:03,100 --> 00:05:07,650 create a summarization tool that can summarize documents, news articles, 77 00:05:07,980 --> 00:05:10,210 research papers, or even books. 78 00:05:11,220 --> 00:05:13,510 These are only a few of the applications 79 00:05:13,520 --> 00:05:16,170 that can be built using LangChain. 80 00:05:16,840 --> 00:05:19,410 When learning LangChain, you will 81 00:05:19,420 --> 00:05:22,050 actually learn about three main concepts. 82 00:05:23,220 --> 00:05:26,790 LangChain components, chains, and agents. 83 00:05:27,660 --> 00:05:29,490 Let's see the LangChain components. 84 00:05:30,130 --> 00:05:33,590 First off, we have the LLM wrappers that 85 00:05:33,600 --> 00:05:40,530 allow us to connect to and use large language models like GPT -4 or those from 86 00:05:40,540 --> 00:05:41,690 the Hugging Face Hub. 87 00:05:42,700 --> 00:05:45,930 Next, there are the prompt templates that 88 00:05:45,940 --> 00:05:50,570 allow us to create dynamic prompts which are the input to the LLMs. 89 00:05:51,480 --> 00:05:56,390 Indexes allow us to extract relevant information for the LLMs. 90 00:05:57,140 --> 00:06:04,170 And memory is the concept of storing and retrieving data in the process of a conversation. 91 00:06:04,880 --> 00:06:09,530 There are two main types of memory, short -term and long -term. 92 00:06:10,000 --> 00:06:15,070 Short -term memory generally refers to how to pass data in the context of a 93 00:06:15,080 --> 00:06:21,510 single conversation and long -term memory deals with how to fetch and update 94 00:06:21,520 --> 00:06:23,930 information between conversations. 95 00:06:24,980 --> 00:06:27,430 Chains allow us to combine multiple 96 00:06:27,440 --> 00:06:34,230 components together to solve a specific task and build an entire LLM application. 97 00:06:35,380 --> 00:06:42,950 And agents facilitate interaction between the LLM and external APIs. 98 00:06:43,440 --> 00:06:50,370 They play a crucial role in decision -making determining which actions the LLM 99 00:06:50,380 --> 00:06:51,690 should undertake. 100 00:06:52,420 --> 00:06:56,030 Agents are enabling tools for LLMs. 101 00:06:56,940 --> 00:07:03,050 This process involves taking an action, observing the result, and then repeating 102 00:07:03,060 --> 00:07:05,150 the cycle until completion. 103 00:07:05,980 --> 00:07:08,630 Ok, we'll take a break and in the next 104 00:07:08,640 --> 00:07:13,030 video, we'll move on to coding and go deeper into each LLM concept.