We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
기본 RAG에서 Agentic RAG로 | RAG 파이프라인을 다중 에이전트 파이프라인의 도구로 사용하세요
0:00 a lot of us heard about rag or retrieval
0:02 augmented generation but maybe not many
0:04 have heard about agentic rag or agent
0:06 based rag application and this is
0:08 exactly what we're going to look at in
0:10 this video now a typical drag
0:12 application have two different pipelines
0:14 one is to ingest data and the other one
0:17 is to query data or ask questions to it
0:20 now what we're seeing is we take our
0:21 documents we convert that into some sort
0:24 of vectors or embeddings and from there
0:26 we store it in a vector database and
0:28 then we can query based on that now this
0:31 step is same for the agent based rag or
0:34 a usual rag application what changes is
0:37 that in a typical drag application the
0:40 user asks questions and we convert that
0:43 question into embeddings and then we
0:45 search for answers in our Vector
0:47 database we send it to an LM and we say
0:51 this is the context and based on the
0:53 user question give an answer to the user
0:57 but this changes a little bit in agent
1:00 based rag application where now we have
1:02 an agent which has memory associated
1:05 with it and also we can select any of
1:08 the llm providers that we want and now
1:10 the key thing is the rag query pipeline
1:14 becomes a tool for this agent so if it
1:17 sees that it needs to query the answer
1:20 from the vector database then it's going
1:23 to go through the usual process and if
1:25 it sees that that's not needed if it can
1:27 just answer a question based on its own
1:29 knowledge then it's just going to go
1:31 ahead and answer that question this
1:33 opens up the possibilities now you can
1:35 attach multiple tools you can attach
1:37 something like an internet search tool
1:39 so if the agent sees that there is a
1:41 need to search internet it can do that
1:44 if it needs to call the vector database
1:46 it's going to do that or if it is
1:47 something within its own knowledge then
1:49 it's going to provide the answer so this
1:51 gives a lot more flexibility in
1:53 comparison to just a rag pipeline where
1:56 it's either going to answer based on the
1:58 vector database or it's going to say I
2:00 don't know the answer so probably one of
2:02 the easiest way to build this agent
2:03 based drag application is using langlow
2:06 and that's what we're going to look at
2:07 so we're going to start with a template
2:09 in langlow so this is the hosted version
2:12 of langlow so you can go to as.
2:14 data.com and then you can make a free
2:17 account and once you start a new account
2:19 you'll see that you will be landed at
2:22 the Astra DB this is the default so in
2:25 here what you want to do is make a
2:27 vector database what I did is I went
2:29 into database es and I created a new
2:31 database for langlow now the name I
2:33 called is langlow you can call any name
2:36 and once you create this now you can
2:38 head over to langlow now if you already
2:40 have a few projects you'll see them
2:42 listed here if it is something new
2:44 you'll see a page with welcome and then
2:46 a few templates so we're going to start
2:48 with a template that's very common so
2:50 this is the vector store Rag and then
2:52 we'll modify this to convert it into a
2:56 gentic rag application so right away
2:58 when you start this template you'll
2:59 notice that there are two different
3:01 flows Happening Here the one at the
3:03 bottom is where we are going to ingest
3:05 data and the one at the top is where we
3:08 can ask questions so this is a typical
3:11 rag application we are starting with a
3:14 file and then we do some sort of
3:17 splitting or chunking and then we store
3:20 that text into the vector database now
3:24 for our case where we have Astra DB this
3:28 component is already available in the
3:30 template if you already have a database
3:32 you're going to select that database and
3:34 then you can provide either a name that
3:37 you have said before or you can start a
3:40 new collection and and basically this
3:42 collection is where you're going to save
3:43 your embeddings now this step remains
3:46 same for any rag pipeline what we're
3:48 going to change is we will modify this
3:52 pipeline here where we can query and get
3:54 answers so instead of just calling open
3:57 AI directly based on the context that we
4:00 get this is going to be an agent I have
4:03 modified a few things so what you will
4:06 notice is that our Astra DB this
4:09 component Remains the Same we are going
4:11 to select the same collection as well as
4:14 the same database and then we have the
4:16 same embeddings that we use so the
4:19 embeddings that we used for data
4:21 ingestion we're going to use the same
4:23 embedding model now next step is that we
4:25 are going to connect this to a retriever
4:28 tool if you were to search in the
4:30 components you'll see that this is
4:32 available so we're just going to bring
4:34 that over and then we attach the Astra
4:38 DB as Retriever and pull the data that
4:41 we get from the DB into retriever tool
4:44 as needed and now this retriever tool is
4:47 what we're going to use with agent
4:49 agents are quite powerful in the new
4:52 Lang flow starting from version 1.1 so
4:55 you'll notice that there is a lot more
4:58 flexibility you can call different
5:00 providers you can use a lot more tools
5:02 than the version before and on top of
5:05 that you can use this in a tool mode so
5:08 any agent can become a tool as well or
5:11 you can use that as an agent blog so in
5:13 this case we're going to use as an agent
5:15 blog so as you notice here we have the
5:17 retriever tool attached to the agent and
5:20 then any question that's asked by the
5:23 user we bring the chat input directly to
5:27 this agent so this agent has the tools
5:29 for retrieval as well as it has a
5:31 built-in memory and then on the other
5:34 side we have just the chat output so one
5:36 key difference here is going to be in
5:38 the prompt to the agent so previously we
5:41 asked if the context has the response so
5:44 answer based on that if not just say I
5:46 don't know well in this case we have a
5:49 detailed prom and the key over here is
5:53 that we are going to say that you are an
5:55 intelligent agent if a question is asked
5:58 and if the respon response is available
6:00 in the vector database you query and try
6:03 to get the response you can retry if
6:06 needed and if then you don't have
6:08 response then you say I don't know or
6:11 you can answer based on the best
6:13 knowledge that you have we let agent do
6:15 the work query it and get the response
6:17 from the vector database and then
6:19 formulate the response based on that so
6:21 that completes the pipeline for agent
6:23 based rag app so with that if we ask
6:25 question that what is this document
6:28 you'll notice that it goes through a
6:29 thought process so I had asked a few
6:31 different questions so you can see the
6:32 responses now for this particular
6:35 question it looks at the document
6:37 available then it's going to get a few
6:40 different output from the Retriever and
6:43 based on that it's going to answer or
6:45 formulate an answer and then provide
6:47 that back to us as a response so that's
6:50 exactly what we see here as a response
6:53 now if you want to confirm that the tool
6:54 was used or not you can always go into
6:57 the logs and then see what happened in
6:59 the back ground so you'll notice over
7:01 here that there is the usage of
7:03 retriever tool and then based on that we
7:05 were given some response now if we want
7:08 to go One Step Beyond the basic rag what
7:11 we can do is we can attach another tool
7:13 to this agent so we can test if it is
7:15 able to search internet or do certain
7:18 task and also do the retrieval task so
7:21 let's do that we will take our same
7:24 template or flow and then in addition to
7:26 what we had before we're going to add
7:28 the search API component and this is
7:32 available in the components so if you
7:34 were to look at the tools there are
7:37 multiple tools available so you could
7:38 use something like Google search or
7:40 search API or if you want any data
7:43 extracted from a website you can use
7:46 something like fir crawl or if you want
7:48 to get something from Wikipedia you
7:50 could use that as well so there are a
7:52 lot more options available to us so if
7:54 you were to go to search API website
7:56 which is search api. and make a free
7:59 account you get up to 100 free searches
8:02 and that's enough for our particular use
8:04 case so we're going to copy this API key
8:06 and we go back to landf flow and provide
8:09 that API key here and now just with that
8:12 one component we have an agent
8:15 application which can perform retrieval
8:17 as well as search internet now in this
8:20 particular case since we added the
8:22 search API we need to modify the prompt
8:24 to the Asian so what we can do is we can
8:28 add information about the API so
8:30 basically what we're saying is that
8:32 first you can query the vector database
8:34 if you think that the response is in the
8:37 vector database if not you can search
8:39 internet and get the response from the
8:41 internet and then based on that respond
8:43 back to the user the strategy as well as
8:46 the response guidelines over here help
8:48 agent to make that decision and then
8:50 also we mentioned that there are these
8:52 tools available for you in case if you
8:54 want to use them and the description for
8:56 these tools could be changed or modified
8:58 if needed in the tool itself so if you
9:01 were to go to the retriever tool you can
9:03 add some descriptions what type of a
9:06 vector database this is or what type of
9:08 a document this is or in case if you
9:10 want to describe the document a little
9:12 bit saying that this document is about
9:14 the physics paper if that is the
9:16 question asked then you can use this
9:18 tool same thing in the search API now
9:22 this is something where the description
9:24 is provided in the tool you can always
9:27 go in if needed you can change the
9:29 description but even a short description
9:31 like this helps the agent to use the
9:34 tool if needed for searching the
9:36 internet so now if I were to ask
9:38 question from the document that we
9:40 provided then we'll notice that it goes
9:42 to the right tool and it's going to
9:45 retrieve some information and provide
9:47 that information to us and then if we
9:50 were to ask a general question which is
9:52 outside of the document then we'll
9:54 notice that it's going to reach to the
9:56 tool that is appropriate so there is
9:58 some history from the previous question
10:00 next question is where I asked about the
10:03 recent Olympics and the results for that
10:06 so what it's going to do is it's going
10:07 to go to the search API use that tool
10:11 and then it's going to retrieve some
10:12 answers some links and based on those
10:15 links and the available information it's
10:18 going to formulate the response and give
10:20 us the response which is the answer that
10:23 we were looking for again if you want to
10:25 confirm that in the logs you can see
10:28 that we are going to be using the
10:30 retriever tool based on the question as
10:33 well as if needed we are going to be
10:36 using the search API and if needed we
10:38 can always go into the details for these
10:41 logs and see how the agent worked on the
10:44 question that we asked hope this helps
10:46 you get started with your first agent
10:49 Bas rag application feel free to reach
10:51 out if you have any questions
0:00 RAG, 즉 검색 증강 생성에 대해 많이 들어보셨을 텐데요, 에이전트 기반 RAG 애플리케이션, 즉 에이전트 RAG는 생소하신 분들도 계실 겁니다. 그래서 이번 영상에서는 에이전트 RAG에 대해 자세히 알아보겠습니다. 일반적인 RAG 애플리케이션은 데이터를 수집하는 파이프라인과, 수집된 데이터를 기반으로 질문하거나 쿼리하는 파이프라인, 이렇게 두 가지로 구성됩니다.
0:20 보시는 것처럼 문서를 가져와서 벡터나 임베딩 형태로 변환한 다음, 벡터 데이터베이스에 저장하고 이를 기반으로 쿼리하는 방식인데요. 이 과정은 에이전트 기반 RAG나 일반적인 RAG 애플리케이션 모두 동일합니다. 차이점은 일반적인 RAG 애플리케이션에서는 사용자가 질문을 하면, 그 질문을 임베딩으로 변환한 다음 벡터 데이터베이스에서 답변을 검색한다는 점입니다.
0:47 검색된 답변을 LLM에 보내서 컨텍스트를 제공하고, 사용자 질문에 맞춰 답변을 생성하는 거죠. 하지만 에이전트 기반 RAG 애플리케이션은 조금 다릅니다. 여기에는 메모리가 연결된 에이전트가 있고, 원하는 LLM 공급자를 선택할 수도 있습니다.
1:10 핵심은 RAG 쿼리 파이프라인이 이 에이전트의 도구로 활용된다는 점입니다. 따라서 벡터 데이터베이스에서 답변을 쿼리해야 한다고 판단되면 일반적인 RAG 프로세스를 따르고, 필요 없다고 판단되면 자체 지식을 기반으로 질문에 답변할 수도 있습니다.
1:33 이로써 다양한 가능성이 열립니다. 이제 여러 도구를 연결할 수 있게 되는 거죠. 예를 들어 인터넷 검색 도구를 연결해서 에이전트가 인터넷 검색이 필요하다고 판단하면 검색을 수행하고, 벡터 데이터베이스를 호출해야 하는 경우에는 그렇게 하고, 자체 지식으로 답변이 가능한 경우에는 바로 답변을 제공합니다. 따라서 벡터 데이터베이스에만 의존하거나 답변을 모른다고 말하는 기존 RAG 파이프라인에 비해 훨씬 유연하게 대처할 수 있습니다.
2:00 에이전트 기반 RAG 애플리케이션을 구축하는 가장 쉬운 방법 중 하나가 Langflow를 사용하는 건데요, 지금부터 Langflow를 활용해 보겠습니다. Langflow에서 템플릿으로 시작할 건데, 지금 보시는 건 Langflow의 호스팅 버전이므로 as(dot)data(dot)com으로 접속해서 무료 계정을 만들 수 있습니다.
2:17 새 계정을 만들면 Astra DB에 접속하게 됩니다. Astra DB가 기본 설정인데요. 여기서 벡터 데이터베이스를 만들어야 합니다. 저는 데이터베이스로 이동해서 Langflow용 새 데이터베이스를 만들었습니다. 이름을 Langflow라고 지었는데요, 원하시는 대로 지정하시면 됩니다. 이렇게 데이터베이스를 생성하면 Langflow로 이동할 수 있습니다.
2:38 이미 프로젝트가 있다면 목록이 표시될 텐데요, 처음 사용하는 경우에는 환영 메시지와 함께 몇 가지 템플릿이 있는 페이지가 나타납니다. 가장 일반적인 템플릿인 벡터 스토어 RAG로 시작해서, 이를 수정해서 유전적 RAG 애플리케이션으로 변환해 보겠습니다.
2:56 이 템플릿을 시작하면 두 개의 다른 흐름이 실행되고 있다는 것을 알 수 있습니다. 하단은 데이터를 수집하는 곳이고, 상단은 질문을 할 수 있는 곳입니다. 이것이 일반적인 RAG 애플리케이션의 구조입니다. 파일에서 시작해서 데이터를 분할하거나 청킹을 수행한 다음, 해당 텍스트를 벡터 데이터베이스에 저장합니다.
3:24 Astra DB를 사용하고 있다면 이 구성 요소는 템플릿에서 바로 사용할 수 있습니다. 이미 데이터베이스가 있다면 해당 데이터베이스를 선택하고, 이전에 지정한 이름을 입력하거나 새 컬렉션을 시작할 수 있습니다. 기본적으로 이 컬렉션은 임베딩을 저장할 위치입니다.
3:43 이 단계는 모든 RAG 파이프라인에서 동일하게 유지됩니다. 이제 쿼리하고 답변을 얻는 파이프라인을 수정할 건데요. Open AI를 직접 호출하는 대신 에이전트를 활용할 겁니다.
4:03 몇 가지 사항을 수정했습니다. Astra DB, 이 구성 요소는 동일하게 유지됩니다. 동일한 데이터베이스와 동일한 컬렉션을 선택하고, 사용하는 임베딩도 동일하게 사용합니다. 데이터 수집에 사용한 임베딩과 동일한 임베딩 모델을 사용할 겁니다.
4:23 다음 단계는 이를 검색기 도구에 연결하는 겁니다. 구성 요소에서 검색해 보면 사용할 수 있다는 것을 알 수 있습니다. 검색기 도구를 가져와서 Astra DB를 검색기로 연결하고, DB에서 가져온 데이터를 필요에 따라 검색기 도구로 가져옵니다.
4:44 이제 이 검색기 도구를 에이전트와 함께 사용할 겁니다. 에이전트는 버전 1.1부터 시작하는 새로운 Langflow에서 매우 강력해졌기 때문에 훨씬 더 유연하게 사용할 수 있습니다. 이전 버전보다 더 많은 공급자를 호출하고 더 많은 도구를 사용할 수 있으며, 도구 모드에서도 사용할 수 있습니다.
5:08 따라서 모든 에이전트가 도구가 될 수도 있고, 에이전트 블로그로 사용할 수도 있습니다. 이 경우에는 에이전트 블로그로 사용할 겁니다. 보시는 것처럼 검색기 도구가 에이전트에 연결되어 있고, 사용자가 묻는 모든 질문은 채팅 입력을 통해 이 에이전트로 직접 전달됩니다.
5:27 따라서 이 에이전트는 검색 도구와 내장 메모리를 가지고 있으며, 다른 쪽에는 채팅 출력이 있습니다. 여기서 한 가지 중요한 차이점은 에이전트에 대한 프롬프트에 있습니다. 이전에는 컨텍스트에 응답이 있으면 이를 기반으로 답변하라고 요청했고, 그렇지 않으면 모른다고 말하게 했습니다.
5:46 하지만 이번에는 더 자세한 프롬프트를 사용하는데요, 핵심은 당신이 지능형 에이전트라는 점을 강조하는 겁니다. 질문이 있고 벡터 데이터베이스에서 응답을 사용할 수 있는 경우, 쿼리를 통해 응답을 얻으려고 시도합니다. 필요한 경우 다시 시도할 수 있으며, 응답이 없으면 모른다고 말하거나 가지고 있는 최상의 지식을 기반으로 답변할 수 있습니다. 에이전트가
6:15 작업을 수행하고, 쿼리하고, 벡터 데이터베이스에서 응답을 가져온 다음, 이를 기반으로 응답을 공식화하도록 하는 겁니다. 이렇게 해서 에이전트 기반 RAG 앱에 대한 파이프라인이 완성됩니다. 이제 이 문서가 무엇인지 질문하면 에이전트가 사고 과정을 거치는 것을 확인할 수 있습니다.
6:30 몇 가지 다른 질문을 해봤는데요, 응답을 보시면 이 특정 질문의 경우 사용 가능한 문서를 살펴본 다음, 검색기에서 몇 가지 다른 출력을 가져오고, 이를 기반으로 답변하거나 답변을 공식화한 다음, 응답으로 다시 제공합니다. 이것이 바로 응답으로 여기에서 보시는 내용입니다.
6:53 도구가 사용되었는지 확인하려면 언제든지 로그로 이동해서 백그라운드에서 무슨 일이 일어났는지 확인할 수 있습니다. 여기에서 검색기 도구의 사용 내역을 확인할 수 있고, 이를 기반으로 응답이 제공되었음을 알 수 있습니다.
7:07 기본 RAG에서 한 단계 더 나아가려면 이 에이전트에 다른 도구를 연결할 수 있습니다. 인터넷을 검색하거나 특정 작업을 수행하고 검색 작업을 수행할 수 있는지 테스트할 수 있습니다. 한번 해보겠습니다. 동일한 템플릿 또는 흐름을 가져와서 이전과 동일하게 유지하고 검색 API 구성 요소를 추가합니다.
7:31 이 구성 요소는 구성 요소에서 사용할 수 있습니다. 도구를 살펴보면 여러 도구를 사용할 수 있습니다. Google 검색이나 검색 API와 같은 것을 사용하거나, 웹사이트에서 데이터를 추출하려면 Fir 크롤링과 같은 것을 사용하거나, Wikipedia에서 무언가를 가져오려면 그것을 사용할 수도 있습니다.
7:51 따라서 우리에게는 훨씬 더 많은 옵션이 있습니다. search API 웹사이트(search api(dot))로 이동해서 무료 계정을 만들면 최대 100회의 무료 검색을 할 수 있으며, 이는 특정 사용 사례에 충분합니다. 이 API 키를 복사해서 landf flow로 돌아가서 여기에 API 키를 제공할 겁니다.
8:11 이제 해당 구성 요소 하나만으로 검색과 인터넷 검색을 모두 수행할 수 있는 에이전트 애플리케이션이 있습니다. 이 특정 경우에는 검색 API를 추가했으므로 에이전트에 대한 프롬프트를 수정해야 합니다. API에 대한 정보를 추가할 수 있습니다.
8:30 기본적으로 우리가 말하는 것은 응답이 벡터 데이터베이스에 있다고 생각되면 먼저 벡터 데이터베이스를 쿼리할 수 있다는 것입니다. 그렇지 않으면 인터넷을 검색하고 인터넷에서 응답을 가져온 다음, 이를 기반으로 사용자에게 응답합니다. 여기서 전략과 응답 지침은 에이전트가 해당 결정을 내리는 데 도움이 됩니다.
8:50 또한 이러한 도구를 사용하려는 경우 사용할 수 있는 도구가 있으며, 필요한 경우 도구 자체에서 이러한 도구에 대한 설명을 변경하거나 수정할 수 있다고 언급했습니다. 검색기 도구로 이동하면 이것이 어떤 유형의 벡터 데이터베이스인지, 또는 어떤 유형의 문서인지에 대한 설명을 추가하거나, 이 문서가 물리학 논문에 대한 것이라고 문서에 대해 약간 설명할 수 있습니다.
9:16 해당 질문이 제기되면 이 도구를 사용할 수 있습니다. 검색 API에서도 마찬가지입니다. 이제 이것은 도구에 설명이 제공되는 것입니다. 필요한 경우 언제든지 들어가서 설명을 변경할 수 있지만, 이와 같은 짧은 설명도 에이전트가 인터넷 검색에 필요한 경우 도구를 사용하는 데 도움이 됩니다.
9:36 이제 제공한 문서에서 질문을 하면 올바른 도구로 이동하여 일부 정보를 검색하고 해당 정보를 제공하는 것을 알 수 있습니다. 문서 외부에 있는 일반적인 질문을 하면 적절한 도구에 도달하는 것을 알 수 있습니다.
9:57 이전 질문에서 일부 기록이 있습니다. 다음 질문은 최근 올림픽과 그 결과에 대해 질문한 것입니다. 검색 API로 이동하여 해당 도구를 사용하고 일부 답변, 일부 링크를 검색하고, 해당 링크와 사용 가능한 정보를 기반으로 응답을 공식화하고, 우리가 찾고 있던 답변인 응답을 제공합니다.
10:23 다시 말하지만 로그에서 확인하려면 질문에 따라 검색기 도구를 사용하고, 필요한 경우 검색 API를 사용할 것이며, 필요한 경우 언제든지 이러한 로그에 대한 세부 정보로 이동하여 에이전트가 질문에 어떻게 응답했는지 확인할 수 있습니다. 이것이 첫 번째 에이전트 Bas RAG 애플리케이션을 시작하는 데 도움이 되기를 바랍니다. 질문이 있으시면 언제든지 문의하십시오.
번역된 시간: 2025-03-09T08:18:05Z
번역 버전: 3.1 Improved translation step with full context