| <!--Copyright 2020 The HuggingFace Team. All rights reserved. | |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | |
| the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | |
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| specific language governing permissions and limitations under the License. | |
| โ ๏ธ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be | |
| rendered properly in your Markdown viewer. | |
| --> | |
| # RAG(๊ฒ์ ์ฆ๊ฐ ์์ฑ) [[rag]] | |
| <div class="flex flex-wrap space-x-1"> | |
| <a href="https://huggingface.co/models?filter=rag"> | |
| <img alt="Models" src="https://img.shields.io/badge/All_model_pages-rag-blueviolet"> | |
| </a> | |
| </div> | |
| ## ๊ฐ์ [[overview]] | |
| ๊ฒ์ ์ฆ๊ฐ ์์ฑ(Retrieval-augmented generation, "RAG") ๋ชจ๋ธ์ ์ฌ์ ํ๋ จ๋ ๋ฐ์ง ๊ฒ์(DPR)๊ณผ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋ธ์ ์ฅ์ ์ ๊ฒฐํฉํฉ๋๋ค. RAG ๋ชจ๋ธ์ ๋ฌธ์๋ฅผ ๊ฒ์ํ๊ณ , ์ด๋ฅผ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋ธ์ ์ ๋ฌํ ๋ค์, ์ฃผ๋ณํ(marginalization)๋ฅผ ํตํด ์ถ๋ ฅ์ ์์ฑํฉ๋๋ค. ๊ฒ์๊ธฐ์ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋์ ์ฌ์ ํ๋ จ๋ ๋ชจ๋ธ๋ก ์ด๊ธฐํ๋๋ฉฐ, ํจ๊ป ๋ฏธ์ธ ์กฐ์ ๋์ด ๊ฒ์๊ณผ ์์ฑ ๋ชจ๋ ๋ค์ด์คํธ๋ฆผ ์์ (๋ชจ๋ธ์ ํน์ ํ์คํฌ์ ์ ์ฉํ๋ ๊ฒ)์ ์ ์ํ ์ ์๊ฒ ํฉ๋๋ค. | |
| ์ด ๋ชจ๋ธ์ Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Kรผttler, Mike Lewis, Wen-tau Yih, Tim Rocktรคschel, Sebastian Riedel, Douwe Kiela์ ๋ ผ๋ฌธ [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://huggingface.co/papers/2005.11401)๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค. | |
| ๋ ผ๋ฌธ์ ์ด๋ก์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. | |
| *๋๊ท๋ชจ ์ฌ์ ํ๋ จ ์ธ์ด ๋ชจ๋ธ๋ค์ ๊ทธ๋ค์ ๋งค๊ฐ๋ณ์์ ์ฌ์ค์ ์ง์์ ์ ์ฅํ๊ณ ์์ผ๋ฉฐ, ๋ค์ด์คํธ๋ฆผ NLP ์์ ์ ๋ํด ๋ฏธ์ธ ์กฐ์ ๋ ๋ ์ต์ฒจ๋จ ๊ฒฐ๊ณผ๋ฅผ ๋ฌ์ฑํฉ๋๋ค. ๊ทธ๋ฌ๋ ์ง์์ ์ ๊ทผํ๊ณ ์ ํํ๊ฒ ์กฐ์ํ๋ ๋ฅ๋ ฅ์ ์ฌ์ ํ ์ ํ์ ์ด๋ฉฐ, ๋ฐ๋ผ์ ์ง์ ์ง์ฝ์ ์์ ์์ ๊ทธ๋ค์ ์ฑ๋ฅ์ ์์ ๋ณ ์ํคํ ์ฒ์ ๋นํด ๋ค๋จ์ด์ง๋๋ค. ๋ํ, ๊ทธ๋ค์ ๊ฒฐ์ ์ ๋ํ ๊ทผ๊ฑฐ๋ฅผ ์ ๊ณตํ๊ณ ์ธ๊ณ ์ง์์ ์ ๋ฐ์ดํธํ๋ ๊ฒ์ ์ฌ์ ํ ์ด๋ฆฐ ์ฐ๊ตฌ ๋ฌธ์ ๋ก ๋จ์ ์์ต๋๋ค. ๋ช ์์ ๋น๋งค๊ฐ๋ณ์ ๋ฉ๋ชจ๋ฆฌ์ ๋ํ ๋ฏธ๋ถ ๊ฐ๋ฅํ ์ ๊ทผ ๋ฉ์ปค๋์ฆ์ ๊ฐ์ง ์ฌ์ ํ๋ จ ๋ชจ๋ธ์ ์ด ๋ฌธ์ ๋ฅผ ๊ทน๋ณตํ ์ ์์ง๋ง, ์ง๊ธ๊น์ง๋ ์ถ์ถ์ ๋ค์ด์คํธ๋ฆผ ์์ ์ ๋ํด์๋ง ์ฐ๊ตฌ๋์์ต๋๋ค. ์ฐ๋ฆฌ๋ ์ธ์ด ์์ฑ์ ์ํด ์ฌ์ ํ๋ จ๋ ๋งค๊ฐ๋ณ์ ๋ฐ ๋น๋งค๊ฐ๋ณ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ฒฐํฉํ๋ ๋ชจ๋ธ์ธ ๊ฒ์ ์ฆ๊ฐ ์์ฑ(RAG)์ ๋ํ ์ผ๋ฐ์ ์ธ ๋ชฉ์ ์ ๋ฏธ์ธ ์กฐ์ ๋ฐฉ๋ฒ์ ํ๊ตฌํฉ๋๋ค. ์ฐ๋ฆฌ๋ ๋งค๊ฐ๋ณ์ ๋ฉ๋ชจ๋ฆฌ๊ฐ ์ฌ์ ํ๋ จ๋ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋ธ์ด๊ณ ๋น๋งค๊ฐ๋ณ์ ๋ฉ๋ชจ๋ฆฌ๊ฐ ์ฌ์ ํ๋ จ๋ ์ ๊ฒฝ ๊ฒ์๊ธฐ๋ก ์ ๊ทผ๋๋ ์ํคํผ๋์์ ๋ฐ์ง ๋ฒกํฐ ์ธ๋ฑ์ค์ธ RAG ๋ชจ๋ธ์ ์๊ฐํฉ๋๋ค. ์ฐ๋ฆฌ๋ ์์ฑ๋ ์ ์ฒด ์ํ์ค์ ๊ฑธ์ณ ๋์ผํ ๊ฒ์๋ ๊ตฌ์ ์ ์กฐ๊ฑด์ผ๋ก ํ๋ RAG ๊ณต์๊ณผ ํ ํฐ๋ณ๋ก ๋ค๋ฅธ ๊ตฌ์ ์ ์ฌ์ฉํ ์ ์๋ RAG ๊ณต์์ ๋น๊ตํฉ๋๋ค. ์ฐ๋ฆฌ๋ ๊ด๋ฒ์ํ ์ง์ ์ง์ฝ์ NLP ์์ ์ ๋ํด ๋ชจ๋ธ์ ๋ฏธ์ธ ์กฐ์ ํ๊ณ ํ๊ฐํ๋ฉฐ, ๋งค๊ฐ๋ณ์ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋ธ๊ณผ ์์ ๋ณ ๊ฒ์-์ถ์ถ ์ํคํ ์ฒ๋ฅผ ๋ฅ๊ฐํ์ฌ ์ธ ๊ฐ์ง ๊ฐ๋ฐฉํ ๋๋ฉ์ธ QA ์์ ์์ ์ต์ฒจ๋จ ์ฑ๋ฅ์ ๋ฌ์ฑํฉ๋๋ค. ์ธ์ด ์์ฑ ์์ ์ ๊ฒฝ์ฐ, RAG ๋ชจ๋ธ์ด ์ต์ฒจ๋จ ๋งค๊ฐ๋ณ์ ์ ์ฉ ์ํ์ค-ํฌ-์ํ์ค ๊ธฐ์ค์ ๋ณด๋ค ๋ ๊ตฌ์ฒด์ ์ด๊ณ , ๋ค์ํ๋ฉฐ, ์ฌ์ค์ ์ธ ์ธ์ด๋ฅผ ์์ฑํ๋ค๋ ๊ฒ์ ๋ฐ๊ฒฌํ์ต๋๋ค.* | |
| ์ด ๋ชจ๋ธ์ [ola13](https://huggingface.co/ola13)์ ์ํด ๊ธฐ์ฌ๋์์ต๋๋ค. | |
| ## ์ฌ์ฉ ํ [[usage-tips]] | |
| ๊ฒ์ ์ฆ๊ฐ ์์ฑ(Retrieval-augmented generation, "RAG") ๋ชจ๋ธ์ ์ฌ์ ํ๋ จ๋ ๋ฐ์ง ๊ฒ์(DPR)๊ณผ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋ธ์ ๊ฐ์ ์ ๊ฒฐํฉํฉ๋๋ค. RAG ๋ชจ๋ธ์ ๋ฌธ์๋ฅผ ๊ฒ์ํ๊ณ , ์ด๋ฅผ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋ธ์ ์ ๋ฌํ ๋ค์, ์ฃผ๋ณํ(marginalization)๋ฅผ ํตํด ์ถ๋ ฅ์ ์์ฑํฉ๋๋ค. ๊ฒ์๊ธฐ์ ์ํ์ค-ํฌ-์ํ์ค ๋ชจ๋์ ์ฌ์ ํ๋ จ๋ ๋ชจ๋ธ๋ก ์ด๊ธฐํ๋๋ฉฐ, ํจ๊ป ๋ฏธ์ธ ์กฐ์ ๋ฉ๋๋ค. ์ด๋ฅผ ํตํด ๊ฒ์๊ณผ ์์ฑ ๋ชจ๋ ๋ค์ด์คํธ๋ฆผ ์์ ์ ์ ์ํ ์ ์๊ฒ ๋ฉ๋๋ค. | |
| ## RagConfig [[transformers.RagConfig]] | |
| [[autodoc]] RagConfig | |
| ## RagTokenizer [[transformers.RagTokenizer]] | |
| [[autodoc]] RagTokenizer | |
| ## Rag specific outputs [[transformers.models.rag.modeling_rag.RetrievAugLMMarginOutput]] | |
| [[autodoc]] models.rag.modeling_rag.RetrievAugLMMarginOutput | |
| [[autodoc]] models.rag.modeling_rag.RetrievAugLMOutput | |
| ## RagRetriever [[transformers.RagRetriever]] | |
| [[autodoc]] RagRetriever | |
| <frameworkcontent> | |
| <pt> | |
| ## RagModel [[transformers.RagModel]] | |
| [[autodoc]] RagModel | |
| - forward | |
| ## RagSequenceForGeneration [[transformers.RagSequenceForGeneration]] | |
| [[autodoc]] RagSequenceForGeneration | |
| - forward | |
| - generate | |
| ## RagTokenForGeneration [[transformers.RagTokenForGeneration]] | |
| [[autodoc]] RagTokenForGeneration | |
| - forward | |
| - generate | |
| </pt> | |
| <tf> | |
| ## TFRagModel [[transformers.TFRagModel]] | |
| [[autodoc]] TFRagModel | |
| - call | |
| ## TFRagSequenceForGeneration [[transformers.TFRagSequenceForGeneration]] | |
| [[autodoc]] TFRagSequenceForGeneration | |
| - call | |
| - generate | |
| ## TFRagTokenForGeneration [[transformers.TFRagTokenForGeneration]] | |
| [[autodoc]] TFRagTokenForGeneration | |
| - call | |
| - generate | |
| </tf> | |
| </frameworkcontent> | |