{"id":461943,"date":"2025-06-03T15:03:52","date_gmt":"2025-06-03T15:03:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=461943"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=461943","title":{"rendered":"<span>Self-RAG: LLM \u0441\u0430\u043c\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0435\u0439 \u043d\u0443\u0436\u0435\u043d \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/275\/7c5\/63e\/2757c563eb70a281b4d6f1171d989858.png\" width=\"1280\" height=\"722\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/275\/7c5\/63e\/2757c563eb70a281b4d6f1171d989858.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/275\/7c5\/63e\/2757c563eb70a281b4d6f1171d989858.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u044b! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043a\u0430\u043a \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f LLM-\u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043e\u0432, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438. \u041f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u043e\u043f\u044b\u0442\u043e\u043c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Self-RAG, \u0435\u0451 \u043f\u043b\u044e\u0441\u0430\u043c\u0438, \u043c\u0438\u043d\u0443\u0441\u0430\u043c\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435.  <\/p>\n<h2>\u041a\u0430\u043a \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u044d\u0442\u043e\u043c\u0443<\/h2>\n<p>\u041c\u044b \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043b\u0438 \u0443 \u0441\u0435\u0431\u044f LLM \u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c RAG \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438:  <\/p>\n<ol>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0439 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0443 \u044e\u0437\u0435\u0440\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438, \u043d\u043e \u043c\u044b \u043b\u0435\u0437\u0435\u043c \u0442\u0443\u0434\u0430 \u0432\u0441\u0435-\u0440\u0430\u0432\u043d\u043e &#8212; \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u043b\u0438\u0448\u043d\u0438\u0435 \u0442\u0440\u0430\u0442\u044b  <\/p>\n<\/li>\n<li>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e Self-RAG \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u0442\u0440\u0430\u0442, \u0445\u043e\u0442\u044c \u044d\u0442\u043e \u0438 \u0434\u0430\u0441\u0442 \u0432\u044b\u0448\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u043c RAG \u0447\u0438\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u044b\u043b\u043e \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u043b\u043e \u0446\u0435\u043d\u0443 \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430 \u043f\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435.  <\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0435\u0448\u0430\u044f \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u043e Self-RAG \u0438 \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c!<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Self-RAG  <\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c \u0432\u043e\u043f\u0440\u043e\u0441 \u043a LLM \u0438\u0434\u0435\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430, \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0433\u0434\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0443\u0436\u0435\u043d-\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u043e\u0434\u0443\u043b\u044c self-rag, \u0433\u0434\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0438\u0434\u0435\u0442 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u0440\u0438\u0442\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e \u0442\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043e\u0446\u0435\u043d\u043a\u0438 \u043c\u0435\u0442\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0432\u0430\u0448 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dc6\/5de\/035\/dc65de0350837708201e18f430b27e7c.png\" width=\"8948\" height=\"4734\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/dc6\/5de\/035\/dc65de0350837708201e18f430b27e7c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dc6\/5de\/035\/dc65de0350837708201e18f430b27e7c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c self-rag \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u043f\u043e\u0438\u0437\u0443\u0447\u0430\u0432 \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u0437\u044f\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445 \u043c\u043e\u0434\u0443\u043b\u044f \u043e\u0442 langchain, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0442\u0430\u043a:  <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/349\/e59\/3b8\/349e593b841369be31be8f77e5720bff.png\" width=\"754\" height=\"262\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/349\/e59\/3b8\/349e593b841369be31be8f77e5720bff.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/349\/e59\/3b8\/349e593b841369be31be8f77e5720bff.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c RAG \u043c\u044b \u0438\u0434\u0435\u043c \u0432 \u043c\u043e\u0434\u0443\u043b\u044c, \u0433\u0434\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432:  <\/p>\n<pre><code class=\"python\">from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain_community.document_loaders import WebBaseLoader from langchain_community.vectorstores import Chroma from langchain_ollama import OllamaEmbeddings  urls = [     \"https:\/\/docs.pytorch.org\/docs\/stable\/cuda.html\",     \"https:\/\/docs.pytorch.org\/docs\/stable\/torch_cuda_memory.html\",     \"https:\/\/docs.pytorch.org\/docs\/stable\/distributed.html\", ]  docs = [WebBaseLoader(url).load() for url in urls] docs_list = [item for sublist in docs for item in sublist]  text_splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(     chunk_size=250, chunk_overlap=0 ) doc_splits = text_splitter.split_documents(docs_list)  embeddings = OllamaEmbeddings(model=\"nomic-embed-text\")  vectorstore = Chroma.from_documents(     documents=doc_splits,     collection_name=\"rag-chroma\",     embedding=embeddings, )   retriever = vectorstore.as_retriever()<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430 \u043e\u0446\u0435\u043d\u043a\u0443 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u0433\u0434\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0435\u043b\u044c\u043a\u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0434\u043e\u0448\u043b\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441:  <\/p>\n<pre><code class=\"python\">from langchain_core.prompts import ChatPromptTemplate from langchain_ollama import ChatOllama  from pydantic import BaseModel, Field from retriver import retriever   class GradeDocuments(BaseModel):     \"\"\"Binary score for relevance check on retrieved documents.\"\"\"      binary_score: str = Field(         description=\"Documents are relevant to the question, 'yes' or 'no'\"     )  llm = ChatOllama(model=\"mistral:instruct\", options={\"temperature\": 0}) structured_llm_grader = llm.with_structured_output(GradeDocuments)  system = \"\"\"You are a grader assessing relevance of a retrieved document to a user question. \\n      It does not need to be a stringent test. The goal is to filter out erroneous retrievals. \\n     If the document contains keyword(s) or semantic meaning related to the user question, grade it as relevant. \\n     Give a binary score 'yes' or 'no' score to indicate whether the document is relevant to the question.\"\"\" grade_prompt = ChatPromptTemplate.from_messages(     [         (\"system\", system),         (\"human\", \"Retrieved document: \\n\\n {document} \\n\\n User question: {question}\"),     ] )  retrieval_grader = grade_prompt | structured_llm_grader  question = \"agent memory\" docs = retriever.invoke(question) <\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0438\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0442\u043e \u0432\u043e \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0443 \u043c\u044b \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c 0. \u0414\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043c\u044b \u0432 \u0446\u0435\u043b\u044f\u0445 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043e\u0446\u0435\u043d\u043a\u0430\u0445, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0438\u0441\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0439.  <\/p>\n<pre><code class=\"python\">from langchain import hub from langchain_core.output_parsers import StrOutputParser from langchain_ollama import ChatOllama from retrivial_greader import docs   prompt = hub.pull(\"rlm\/rag-prompt\")  llm = ChatOllama(model=\"qwen3:1.7b\", options={\"temperature\": 0})  def format_docs(docs):     return \"\\n\\n\".join(doc.page_content for doc in docs)  rag_chain = prompt | llm | StrOutputParser() question = \"agent memory\"  generation = rag_chain.invoke({\"context\": docs, \"question\": question}) <\/code><\/pre>\n<p>\u0418 \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0442\u0430\u043b\u043e \u0432\u0441\u0435-\u0440\u0430\u0432\u043d\u043e \u043d\u0430 \u043d\u0430\u0448\u0443 \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u043c\u0435\u0440\u0443 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"python\">from pydantic import BaseModel, Field from langchain_ollama import ChatOllama from langchain_core.prompts import ChatPromptTemplate from generator import generation from retrivial_greader import docs  class GradeHallucinations(BaseModel):     \"\"\"Binary score for hallucination present in generation answer.\"\"\"      binary_score: str = Field(         description=\"Answer is grounded in the facts, 'yes' or 'no'\"     )   llm = ChatOllama(model=\"qwen3:1.7B\", options={\"temperature\": 0}) structured_llm_grader = llm.with_structured_output(GradeHallucinations)  system = \"\"\"You are a strict grader.  You must answer ONLY with 'yes' or 'no' and NOTHING else.  Rule: - Answer 'yes' if the generation is grounded in or supported by the documents. - Answer 'no' if the generation contains hallucinations or is not grounded.  Do not explain. Do not output any extra text. \"\"\"   hallucination_prompt = ChatPromptTemplate.from_messages(     [         (\"system\", system),         (\"human\", \"Set of facts: \\n\\n {documents} \\n\\n LLM generation: {generation}. Is the generation grounded in the documents? Answer only with 'yes' or 'no'.\"),     ] )    question = \"agent memory\"  hallucination_grader = hallucination_prompt | structured_llm_grader score = hallucination_grader.invoke({\"documents\": docs, \"generation\": generation})<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441:  <\/p>\n<pre><code class=\"python\">from pydantic import BaseModel, Field from langchain_core.prompts import ChatPromptTemplate from langchain_ollama import ChatOllama from retriver import retriever from generator import rag_chain   class GradeAnswer(BaseModel):     \"\"\"Binary score to assess answer addresses question.\"\"\"     binary_score: str = Field(         description=\"Answer addresses the question, 'yes' or 'no'\"     )  llm = ChatOllama(model=\"qwen3:1.7b\", options={\"temperature\": 0}) structured_llm_grader = llm.with_structured_output(GradeAnswer)  system = \"\"\"You are a grader assessing whether an answer addresses \/ resolves a question. Respond only with a JSON object containing the field 'binary_score', either \"yes\" or \"no\". Do not include any explanations or additional text.\"\"\" answer_prompt = ChatPromptTemplate.from_messages([     (\"system\", system),     (\"human\", \"User question: \\n\\n {question} \\n\\n LLM generation: {generation}\"), ])   answer_grader = answer_prompt | structured_llm_grader  question = \"agent memory\" docs = retriever.invoke(question) generation = rag_chain.invoke({\"context\": docs, \"question\": question})  result = answer_grader.invoke({\"question\": question, \"generation\": generation})  <\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043c\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0437\u043b\u044b \u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432\u044b\u0448\u0435 \u0432 \u0433\u0440\u0430\u0444, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u043d\u0430\u0448\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c\u043a\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0437\u044f\u0442\u044b \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430, \u043f\u0440\u043e\u043c\u0442\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0434 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432.<\/p>\n<h2>\u0413\u043b\u0430\u0434\u043a\u043e \u0431\u044b\u043b\u043e \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435&#8230;<\/h2>\n<h2>\u0411\u0443\u0434\u044c \u0443\u0432\u0435\u0440\u0435\u043d, \u043d\u043e \u0432 \u043c\u0435\u0440\u0443<\/h2>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u044d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044c \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0435\u0448\u0430\u0442\u044c \u043d\u0443\u0436\u0435\u043d \u043b\u0438 \u0435\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442 (\u0441\u043f\u043e\u0439\u043b\u0435\u0440-\u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u043c\u0442 \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442). \u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u0431\u0435\u0440\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u043b\u0438 \u0441 \u0442\u0430\u043a\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f RETRIEVE \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0436\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b &#8212; \u044d\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u043b\u0438\u0448\u043d\u044f\u044f \u0441\u0430\u043c\u043e\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u043b\u0438\u0448\u043d\u044f\u044f \u043d\u0435\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<\/ul>\n<p>\u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430? \u041a\u0430\u043a \u0440\u0430\u0437 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043d\u0435\u0432\u0437\u043d\u0430\u0447\u0430\u0439 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u0438 self-RAG \u0432 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430 <\/p>\n<blockquote>\n<p>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 2+2?<\/p>\n<\/blockquote>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043b\u0435\u0437\u043b\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0430 \u0432\u0441\u0435 \u044d\u0442\u043e \u0440\u0430\u0434\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430<\/p>\n<p>\u041b\u0438\u0431\u043e \u043f\u0440\u0438 \u043b\u0438\u0448\u043d\u0435\u0439 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u043d\u0430 \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u044c\u0431\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0430\u043b\u0430, \u0447\u0442\u043e \u043e\u043d\u0430 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u0442\u0430\u043a \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0432\u044b\u0437\u043e\u0432 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0444\u043b\u0430\u0433\u0430 RETRIEVE \u0432 \u043e\u0442\u0432\u0435\u0442\u0435.<\/p>\n<h2> \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0440\u0430\u0437\u0443\u043c\u043d\u043e  <\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 self-RAG \u0432\u0430\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0436\u0435\u043b\u0435\u0437\u043e (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438). \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439:<\/p>\n<ol>\n<li>\n<p><strong>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043e\u0434\u0438\u043d \u0443\u0437\u0435\u043b<\/strong>.<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u00ab\u043d\u0443\u0436\u0435\u043d \u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c?\u00bb \u0438 \u00ab\u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e?\u00bb \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 LLM. \u042d\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u041f\u0440\u0438 \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0451\u043c\u043a\u0438\u0435 \u044d\u0442\u0430\u043f\u044b \u0438 lightweight-\u043e\u0446\u0435\u043d\u043a\u0438<\/strong>.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Mistral, Qwen-1.5-1.8B) \u0434\u043b\u044f \u0443\u0437\u043b\u043e\u0432 \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0439 \u0438\u043b\u0438 \u00ab\u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e \u0442\u0435\u043c\u0435\u00bb. \u042d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u0451\u0433\u043a\u0438\u043c LLM.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0443\u0437\u043b\u044b \u043e\u0446\u0435\u043d\u043a\u0438<\/strong>.<br \/> \u0423\u0437\u043b\u044b \u0442\u0438\u043f\u0430 \u00ab\u043e\u0446\u0435\u043d\u043a\u0430 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438\u00bb \u0438\u043b\u0438 \u00ab\u0435\u0441\u0442\u044c \u043b\u0438 \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u044f\u00bb \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u2014 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u043e\u0434 \u0432\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435. \u0412\u0435\u0434\u044c \u0432\u0430\u0448\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438\u043b\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043f\u043e\u0434 \u0442\u0443 \u0438\u043b\u0438 \u0438\u043d\u0443\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0443\u043d\u043a\u0442\u044b \u0437\u0432\u0443\u0447\u0430\u0442 \u043f\u0440\u043e\u0441\u0442\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u043b\u0438 \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442 \u0438\u043b\u0438 \u0437\u0430\u0431\u0438\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u043d\u0430 \u044d\u0442\u043e\u0442  \u0448\u0430\u0433.<\/p>\n<p>\u041a\u043e\u0434 \u0432\u044b\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h2>\u0410 \u0432 \u0447\u0435\u043c \u0436\u0435 \u0432\u044b\u0438\u0433\u0440\u044b\u0448?<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0442\u0441\u0435\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e \u0443\u0431\u0440\u0430\u043b\u043e \u0447\u0430\u0441\u0442\u044c \u044e\u0437\u0435\u0440\u043e\u0432, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u044e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u0437 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043f\u0443\u0441\u0430 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0410 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 \u0443\u0437\u043b\u0430\u0445, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0430\u0441\u044c \u043d\u0430 6%, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u0438\u043c \u043d\u0443\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u0438\u0437 &#171;\u0431\u0430\u0437\u044b \u0437\u043d\u0430\u043d\u0438\u0439&#187;. \u041f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441 \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c.<\/p>\n<h2>\u041f\u0440\u043e api \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0431\u044b \u043f\u043b\u0430\u0442\u043d\u044b\u0439 api \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u044b \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u044f \u044d\u0442\u043e \u0441 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u0430\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0437\u043b\u044b \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u043f\u043e\u0442\u044f\u043d\u0435\u0442 \u0432\u0430\u0448\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u041a\u0430\u043a \u0438\u0442\u043e\u0433 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u043d\u0430\u043c, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0438 \u0432\u0430\u043c. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u0432\u044b \u044d\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435, \u0442\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f!<\/p>\n<p>\u041a\u0430\u043a \u044f \u0441\u043a\u0430\u0437\u0430\u043b \u0432\u044b\u0448\u0435, \u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u0431\u0435\u0440\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0438\u0434\u0431\u0435\u043a, \u0442\u043e \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u043e\u0446\u0435\u043d\u043a\u0438 \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0438 \u044d\u0442\u043e \u0432\u0441\u0435 \u0432 \u043a\u0440\u0443\u0442\u043e\u0433\u043e \u0444\u0440\u0430\u043d\u043a\u0435\u043d\u0448\u0442\u0435\u0439\u043d\u0430!<\/p>\n<p>\ud83d\udd25 \u0421\u0442\u0430\u0432\u044c\u0442\u0435 \u043b\u0430\u0439\u043a \u0438 \u043f\u0438\u0448\u0438\u0442\u0435, \u043a\u0430\u043a\u0438\u0435 \u0442\u0435\u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435! \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435!<\/p>\n<p>\u2714\ufe0f \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 Telegram-\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 <a href=\"https:\/\/t.me\/+w0V_HEhKSkIyMTYy\" rel=\"noopener noreferrer nofollow\">@datafeeling<\/a>, \u0433\u0434\u0435 \u043c\u044b \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u043d\u043e\u0432\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u0435\u0439\u0441\u0430\u043c\u0438, \u0438\u043d\u0441\u0430\u0439\u0442\u0430\u043c\u0438 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u0434\u0430\u0447\u0430\u043c<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/915038\/\"> https:\/\/habr.com\/ru\/articles\/915038\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u044b! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043a\u0430\u043a \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f LLM-\u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043e\u0432, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438. \u041f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u043e\u043f\u044b\u0442\u043e\u043c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Self-RAG, \u0435\u0451 \u043f\u043b\u044e\u0441\u0430\u043c\u0438, \u043c\u0438\u043d\u0443\u0441\u0430\u043c\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435.  <\/p>\n<h2>\u041a\u0430\u043a \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u044d\u0442\u043e\u043c\u0443<\/h2>\n<p>\u041c\u044b \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043b\u0438 \u0443 \u0441\u0435\u0431\u044f LLM \u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c RAG \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438:  <\/p>\n<ol>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0439 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0443 \u044e\u0437\u0435\u0440\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438, \u043d\u043e \u043c\u044b \u043b\u0435\u0437\u0435\u043c \u0442\u0443\u0434\u0430 \u0432\u0441\u0435-\u0440\u0430\u0432\u043d\u043e &#8212; \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u043b\u0438\u0448\u043d\u0438\u0435 \u0442\u0440\u0430\u0442\u044b  <\/p>\n<\/li>\n<li>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e Self-RAG \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u0442\u0440\u0430\u0442, \u0445\u043e\u0442\u044c \u044d\u0442\u043e \u0438 \u0434\u0430\u0441\u0442 \u0432\u044b\u0448\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u043e\u043c RAG \u0447\u0438\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u044b\u043b\u043e \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u043b\u043e \u0446\u0435\u043d\u0443 \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0441\u0430 \u043f\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435.  <\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0435\u0448\u0430\u044f \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u043e Self-RAG \u0438 \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c!<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Self-RAG  <\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c \u0432\u043e\u043f\u0440\u043e\u0441 \u043a LLM \u0438\u0434\u0435\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430, \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0433\u0434\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0443\u0436\u0435\u043d-\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u043e\u0434\u0443\u043b\u044c self-rag, \u0433\u0434\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0438\u0434\u0435\u0442 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u0440\u0438\u0442\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e \u0442\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043e\u0446\u0435\u043d\u043a\u0438 \u043c\u0435\u0442\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0432\u0430\u0448 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c self-rag \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u043f\u043e\u0438\u0437\u0443\u0447\u0430\u0432 \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u0437\u044f\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445 \u043c\u043e\u0434\u0443\u043b\u044f \u043e\u0442 langchain, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0442\u0430\u043a:  <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c RAG \u043c\u044b \u0438\u0434\u0435\u043c \u0432 \u043c\u043e\u0434\u0443\u043b\u044c, \u0433\u0434\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432:  <\/p>\n<pre><code class=\"python\">from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain_community.document_loaders import WebBaseLoader from langchain_community.vectorstores import Chroma from langchain_ollama import OllamaEmbeddings  urls = [     \"https:\/\/docs.pytorch.org\/docs\/stable\/cuda.html\",     \"https:\/\/docs.pytorch.org\/docs\/stable\/torch_cuda_memory.html\",     \"https:\/\/docs.pytorch.org\/docs\/stable\/distributed.html\", ]  docs = [WebBaseLoader(url).load() for url in urls] docs_list = [item for sublist in docs for item in sublist]  text_splitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(     chunk_size=250, chunk_overlap=0 ) doc_splits = text_splitter.split_documents(docs_list)  embeddings = OllamaEmbeddings(model=\"nomic-embed-text\")  vectorstore = Chroma.from_documents(     documents=doc_splits,     collection_name=\"rag-chroma\",     embedding=embeddings, )   retriever = vectorstore.as_retriever()<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430 \u043e\u0446\u0435\u043d\u043a\u0443 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u0433\u0434\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0435\u043b\u044c\u043a\u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0434\u043e\u0448\u043b\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441:  <\/p>\n<pre><code class=\"python\">from langchain_core.prompts import ChatPromptTemplate from langchain_ollama import ChatOllama  from pydantic import BaseModel, Field from retriver import retriever   class GradeDocuments(BaseModel):     \"\"\"Binary score for relevance check on retrieved documents.\"\"\"      binary_score: str = Field(         description=\"Documents are relevant to the question, 'yes' or 'no'\"     )  llm = ChatOllama(model=\"mistral:instruct\", options={\"temperature\": 0}) structured_llm_grader = llm.with_structured_output(GradeDocuments)  system = \"\"\"You are a grader assessing relevance of a retrieved document to a user question. \\n      It does not need to be a stringent test. The goal is to filter out erroneous retrievals. \\n     If the document contains keyword(s) or semantic meaning related to the user question, grade it as relevant. \\n     Give a binary score 'yes' or 'no' score to indicate whether the document is relevant to the question.\"\"\" grade_prompt = ChatPromptTemplate.from_messages(     [         (\"system\", system),         (\"human\", \"Retrieved document: \\n\\n {document} \\n\\n User question: {question}\"),     ] )  retrieval_grader = grade_prompt | structured_llm_grader  question = \"agent memory\" docs = retriever.invoke(question) <\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0438\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0442\u043e \u0432\u043e \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0443 \u043c\u044b \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c 0. \u0414\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043c\u044b \u0432 \u0446\u0435\u043b\u044f\u0445 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043e\u0446\u0435\u043d\u043a\u0430\u0445, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0438\u0441\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0439.  <\/p>\n<pre><code class=\"python\">from langchain import hub from langchain_core.output_parsers import StrOutputParser from langchain_ollama import ChatOllama from retrivial_greader import docs   prompt = hub.pull(\"rlm\/rag-prompt\")  llm = ChatOllama(model=\"qwen3:1.7b\", options={\"temperature\": 0})  def format_docs(docs):     return \"\\n\\n\".join(doc.page_content for doc in docs)  rag_chain = prompt | llm | StrOutputParser() question = \"agent memory\"  generation = rag_chain.invoke({\"context\": docs, \"question\": question}) <\/code><\/pre>\n<p>\u0418 \u043a\u0430\u043a \u0440\u0430\u0437 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0442\u0430\u043b\u043e \u0432\u0441\u0435-\u0440\u0430\u0432\u043d\u043e \u043d\u0430 \u043d\u0430\u0448\u0443 \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u043c\u0435\u0440\u0443 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"python\">from pydantic import BaseModel, Field from langchain_ollama import ChatOllama from langchain_core.prompts import ChatPromptTemplate from generator import generation from retrivial_greader import docs  class GradeHallucinations(BaseModel):     \"\"\"Binary score for hallucination present in generation answer.\"\"\"      binary_score: str = Field(         description=\"Answer is grounded in the facts, 'yes' or 'no'\"     )   llm = ChatOllama(model=\"qwen3:1.7B\", options={\"temperature\": 0}) structured_llm_grader = llm.with_structured_output(GradeHallucinations)  system = \"\"\"You are a strict grader.  You must answer ONLY with 'yes' or 'no' and NOTHING else.  Rule: - Answer 'yes' if the generation is grounded in or supported by the documents. - Answer 'no' if the generation contains hallucinations or is not grounded.  Do not explain. Do not output any extra text. \"\"\"   hallucination_prompt = ChatPromptTemplate.from_messages(     [         (\"system\", system),         (\"human\", \"Set of facts: \\n\\n {documents} \\n\\n LLM generation: {generation}. Is the generation grounded in the documents? Answer only with 'yes' or 'no'.\"),     ] )    question = \"agent memory\"  hallucination_grader = hallucination_prompt | structured_llm_grader score = hallucination_grader.invoke({\"documents\": docs, \"generation\": generation})<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441:  <\/p>\n<pre><code class=\"python\">from pydantic import BaseModel, Field from langchain_core.prompts import ChatPromptTemplate from langchain_ollama import ChatOllama from retriver import retriever from generator import rag_chain   class GradeAnswer(BaseModel):     \"\"\"Binary score to assess answer addresses question.\"\"\"     binary_score: str = Field(         description=\"Answer addresses the question, 'yes' or 'no'\"     )  llm = ChatOllama(model=\"qwen3:1.7b\", options={\"temperature\": 0}) structured_llm_grader = llm.with_structured_output(GradeAnswer)  system = \"\"\"You are a grader assessing whether an answer addresses \/ resolves a question. Respond only with a JSON object containing the field 'binary_score', either \"yes\" or \"no\". Do not include any explanations or additional text.\"\"\" answer_prompt = ChatPromptTemplate.from_messages([     (\"system\", system),     (\"human\", \"User question: \\n\\n {question} \\n\\n LLM generation: {generation}\"), ])   answer_grader = answer_prompt | structured_llm_grader  question = \"agent memory\" docs = retriever.invoke(question) generation = rag_chain.invoke({\"context\": docs, \"question\": question})  result = answer_grader.invoke({\"question\": question, \"generation\": generation})  <\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043c\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0437\u043b\u044b \u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432\u044b\u0448\u0435 \u0432 \u0433\u0440\u0430\u0444, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u043d\u0430\u0448\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c\u043a\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0437\u044f\u0442\u044b \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430, \u043f\u0440\u043e\u043c\u0442\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0434 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432.<\/p>\n<h2>\u0413\u043b\u0430\u0434\u043a\u043e \u0431\u044b\u043b\u043e \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435&#8230;<\/h2>\n<h2>\u0411\u0443\u0434\u044c \u0443\u0432\u0435\u0440\u0435\u043d, \u043d\u043e \u0432 \u043c\u0435\u0440\u0443<\/h2>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u044d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044c \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0435\u0448\u0430\u0442\u044c \u043d\u0443\u0436\u0435\u043d \u043b\u0438 \u0435\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442 (\u0441\u043f\u043e\u0439\u043b\u0435\u0440-\u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u043c\u0442 \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442). \u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u0431\u0435\u0440\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u043b\u0438 \u0441 \u0442\u0430\u043a\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f RETRIEVE \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0436\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b &#8212; \u044d\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u043b\u0438\u0448\u043d\u044f\u044f \u0441\u0430\u043c\u043e\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p>\u043b\u0438\u0448\u043d\u044f\u044f \u043d\u0435\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c<\/p>\n<\/li>\n<\/ul>\n<p>\u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430? \u041a\u0430\u043a \u0440\u0430\u0437 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u043d\u0435\u0432\u0437\u043d\u0430\u0447\u0430\u0439 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u0438 self-RAG \u0432 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430 <\/p>\n<blockquote>\n<p>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 2+2?<\/p>\n<\/blockquote>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u043b\u0435\u0437\u043b\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0430 \u0432\u0441\u0435 \u044d\u0442\u043e \u0440\u0430\u0434\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430<\/p>\n<p>\u041b\u0438\u0431\u043e \u043f\u0440\u0438 \u043b\u0438\u0448\u043d\u0435\u0439 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u043d\u0430 \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u044c\u0431\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0430\u043b\u0430, \u0447\u0442\u043e \u043e\u043d\u0430 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u0442\u0430\u043a \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0432\u044b\u0437\u043e\u0432 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0444\u043b\u0430\u0433\u0430 RETRIEVE \u0432 \u043e\u0442\u0432\u0435\u0442\u0435.<\/p>\n<h2> \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0440\u0430\u0437\u0443\u043c\u043d\u043e  <\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 self-RAG \u0432\u0430\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0436\u0435\u043b\u0435\u0437\u043e (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438). \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439:<\/p>\n<ol>\n<li>\n<p><strong>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043e\u0434\u0438\u043d \u0443\u0437\u0435\u043b<\/strong>.<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u00ab\u043d\u0443\u0436\u0435\u043d \u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c?\u00bb \u0438 \u00ab\u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e?\u00bb \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 LLM. \u042d\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u041f\u0440\u0438 \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0451\u043c\u043a\u0438\u0435 \u044d\u0442\u0430\u043f\u044b \u0438 lightweight-\u043e\u0446\u0435\u043d\u043a\u0438<\/strong>.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Mistral, Qwen-1.5-1.8B) \u0434\u043b\u044f \u0443\u0437\u043b\u043e\u0432 \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u0439 \u0438\u043b\u0438 \u00ab\u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e \u0442\u0435\u043c\u0435\u00bb. \u042d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u0451\u0433\u043a\u0438\u043c LLM.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0443\u0437\u043b\u044b \u043e\u0446\u0435\u043d\u043a\u0438<\/strong>.<br \/> \u0423\u0437\u043b\u044b \u0442\u0438\u043f\u0430 \u00ab\u043e\u0446\u0435\u043d\u043a\u0430 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438\u00bb \u0438\u043b\u0438 \u00ab\u0435\u0441\u0442\u044c \u043b\u0438 \u0433\u0430\u043b\u043b\u044e\u0446\u0438\u043d\u0430\u0446\u0438\u044f\u00bb \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u2014 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u043e\u0434 \u0432\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435. \u0412\u0435\u0434\u044c \u0432\u0430\u0448\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438\u043b\u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043f\u043e\u0434 \u0442\u0443 \u0438\u043b\u0438 \u0438\u043d\u0443\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0443\u043d\u043a\u0442\u044b \u0437\u0432\u0443\u0447\u0430\u0442 \u043f\u0440\u043e\u0441\u0442\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u043b\u0438 \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442 \u0438\u043b\u0438 \u0437\u0430\u0431\u0438\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u043d\u0430 \u044d\u0442\u043e\u0442  \u0448\u0430\u0433.<\/p>\n<p>\u041a\u043e\u0434 \u0432\u044b\u0448\u0435<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-461943","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/461943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=461943"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/461943\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=461943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=461943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=461943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}