{"id":1636,"date":"2024-12-03T21:45:45","date_gmt":"2024-12-03T13:45:45","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=1636"},"modified":"2024-12-03T21:46:02","modified_gmt":"2024-12-03T13:46:02","slug":"rag-architecture","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=1636","title":{"rendered":"RAG Architecture"},"content":{"rendered":"<p>A typical RAG application has two main components:<\/p>\n<ul>\n<li>\n<p>Indexing: a pipeline for ingesting data from a source and indexing it. This usually happens offline.<\/p>\n<\/li>\n<li>\n<p>Retrieval and generation: the actual RAG chain, which takes the user query at run time and retrieves the relevant data from the index, then passes that to the model.<\/p>\n<\/li>\n<\/ul>\n<p>The most common full sequence from raw data to answer looks like:<\/p>\n<h2>Indexing<\/h2>\n<ul>\n<li>Load: First we need to load our data. This is done with DocumentLoaders.<\/li>\n<li>Split: Text splitters break large Documents into smaller chunks. This is useful both for indexing data and for passing it in to a model, since large chunks are harder to search over and won't fit in a model's finite context window.<\/li>\n<li>Store: We need somewhere to store and index our splits, so that they can later be searched over. This is often done using a VectorStore and Embeddings model.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2024\/12\/image-1733233479607.png\" alt=\"file\" \/><\/p>\n<h2>Retrieval and generation<\/h2>\n<ul>\n<li>Retrieve: Given a user input, relevant splits are retrieved from storage using a Retriever.<\/li>\n<li>Generate: A ChatModel \/ LLM produces an answer using a prompt that includes the question and the retrieved data<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2024\/12\/image-1733233540376.png\" alt=\"file\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A typical RAG application has two main components: Indexing: a pipeline for ingesting data from a source and indexing it. This usually happens offline. Retrieval and generation: the actual RAG chain, which takes the user query at run time and retrieves the relevant data from the index, then passes that to the model. The most [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=1636\" title=\"Permanent Link to: RAG Architecture\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1636","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1636"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1636"}],"version-history":[{"count":2,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1636\/revisions"}],"predecessor-version":[{"id":1640,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1636\/revisions\/1640"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}