๐๐ ๐๐ง๐ญ๐ข๐ ๐๐๐ โจ new cookbook
I just published a new cookbook showing how to easily improve Retrieval Augmented Generation (RAG) with an agent system using Transformers Agents.
Vanilla RAG has the following limitations:
- โค ๐๐ ๐ฟ๐ฒ๐๐ฟ๐ถ๐ฒ๐๐ฒ๐ ๐๐ผ๐๐ฟ๐ฐ๐ฒ ๐ฑ๐ผ๐ฐ๐๐บ๐ฒ๐ป๐ ๐ผ๐ป๐น๐ ๐ผ๐ป๐ฐ๐ฒ: if the retrieved docuents are not relevant enough the generation in turn will be bad.
- โค Semantic similarity is computed ๐ฌ๐๐ฉ๐ ๐ฉ๐๐ ๐ช๐จ๐๐ง ๐ฆ๐ช๐๐ง๐ฎ ๐๐จ ๐ ๐ง๐๐๐๐ง๐๐ฃ๐๐, which is often suboptimal: for instance, the user query will mostly be a question and the document containing the true answer will be in affirmative voice, so its similarity score will be downgraded compared to less relevant source documents in the interrogative form, leading to a risk of not selecting the relevant document.
๐๐๐ ๐๐ฃ๐ ๐ ๐๐ผ๐ ๐๐๐๐ฃ๐ฉ - ๐ซ๐๐ง๐ฎ ๐จ๐๐ข๐ฅ๐ก๐ฎ, ๐๐ฃ ๐๐๐๐ฃ๐ฉ ๐๐ง๐ข๐๐ ๐ฌ๐๐ฉ๐ ๐ ๐ง๐๐ฉ๐ง๐๐๐ซ๐๐ง ๐ฉ๐ค๐ค๐ก - ๐๐ก๐ก๐๐ซ๐๐๐ฉ๐๐จ ๐๐ค๐ฉ๐ ๐ฉ๐๐๐จ๐ ๐ฅ๐ง๐ค๐๐ก๐๐ข๐จ!
- โ Formulate the query itself (query reformulation)
- โ Critique the content to re-retrieve if needed (self-query)
๐๐ผ๐ ๐บ๐๐ฐ๐ต ๐ฑ๐ผ๐ฒ๐ ๐๐ต๐ถ๐ ๐ฎ๐ด๐ฒ๐ป๐๐ถ๐ฐ ๐๐ฒ๐๐๐ฝ ๐ถ๐บ๐ฝ๐ฟ๐ผ๐๐ฒ ๐ฟ๐ฒ๐๐๐น๐๐? Iโve added to the cookbook an evaluation part with LLM-as-a-judge using Llama-3-70B. When switching from vanilla to agentic RAG, the ๐๐ฐ๐ผ๐ฟ๐ฒ ๐ถ๐ป๐ฐ๐ฟ๐ฒ๐ฎ๐๐ฒ๐ ๐ฏ๐ ๐ด.๐ฑ%! ๐ช (from 70.0% to 78.5%)
One important drawback though: since the system is now doing several LLM calls instead of 1, the runtime of the RAG system also increases. You have to find the right trade-off!
๐๐ถ๐๐ฐ๐ผ๐๐ฒ๐ฟ ๐๐ต๐ฒ ๐ฐ๐ผ๐ผ๐ธ๐ฏ๐ผ๐ผ๐ธ ๐
๐๐ด๐ฒ๐ป๐๐ถ๐ฐ ๐๐ฎ๐๐ฎ ๐ฎ๐ป๐ฎ๐น๐๐๐: ๐ฑ๐ฟ๐ผ๐ฝ ๐๐ผ๐๐ฟ ๐ฑ๐ฎ๐๐ฎ ๐ณ๐ถ๐น๐ฒ, ๐น๐ฒ๐ ๐๐ต๐ฒ ๐๐๐ ๐ฑ๐ผ ๐๐ต๐ฒ ๐ฎ๐ป๐ฎ๐น๐๐๐ถ๐ ๐โ๏ธ
Need to make quick exploratory data analysis? โก๏ธ Get help from an agent.
I was impressed by Llama-3.1โs capacity to derive insights from data. Given a csv file, it makes quick work of exploratory data analysis and can derive interesting insights.
On the data from the Kaggle titanic challenge, that records which passengers survived the Titanic wreckage, it was able by itself to derive interesting trends like โpassengers that paid higher fares were more likely to surviveโ or โsurvival rate was much higher for women than menโ.
The cookbook even lets the agent built its own submission to the challenge, and it ranks under 3,000 out of 17,000 submissions: ๐ not bad at all!
- Try it for yourself in this Space demo ๐ https://lnkd.in/gzaqQ3rT
- Read the cookbook to dive deeper ๐ https://lnkd.in/gXx3-AyH
Translate to Korean
๋ฐฉ๊ธ Transformers Agents๋ฅผ ์ฌ์ฉํ์ฌ ์์ด์ ํธ ์์คํ ์ผ๋ก RAG(Retrieval Augmented Generation)๋ฅผ ์ฝ๊ฒ ๊ฐ์ ํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ฃผ๋ ์๋ก์ด ์ฟก๋ถ์ ์ถํํ์ต๋๋ค.
Vanilla RAG์๋ ๋ค์๊ณผ ๊ฐ์ ์ ํ ์ฌํญ์ด ์์ต๋๋ค.
- โค ์์ค ๋ฌธ์๋ฅผ ํ ๋ฒ๋ง ๊ฒ์ํฉ๋๋ค: ๊ฒ์๋ ๋ฌธ์๊ฐ ์ถฉ๋ถํ ๊ด๋ จ์ฑ์ด ์์ผ๋ฉด ์์ฑ์ด ๋๋น ์ง ๊ฒ์ ๋๋ค.
- โค ์๋ฏธ๋ก ์ ์ ์ฌ์ฑ์ ์ฌ์ฉ์ ์ฟผ๋ฆฌ๋ฅผ ์ฐธ์กฐ๋ก ์ฌ์ฉํ์ฌ ๊ณ์ฐ๋๋ฉฐ, ์ด๋ ์ข ์ข ์ฐจ์ ์ฑ ์ ๋๋ค: ์๋ฅผ ๋ค์ด, ์ฌ์ฉ์ ์ฟผ๋ฆฌ๋ ๋๋ถ๋ถ ์ง๋ฌธ์ด๊ณ ์ค์ ๋ต๋ณ์ ํฌํจํ๋ ๋ฌธ์๋ ๊ธ์ ์์ฑ์ด๋ฏ๋ก ์ ์ฌ์ฑ ์ ์๋ ์๋ฌธ ํ์์ ๊ด๋ จ์ฑ์ด ๋ฎ์ ์์ค ๋ฌธ์์ ๋นํด ๋ค์ด๊ทธ๋ ์ด๋๋์ด ๊ด๋ จ ๋ฌธ์๋ฅผ ์ ํํ์ง ์์ ์ํ์ด ์์ต๋๋ค.
RAG ์์ด์ ํธ๋ฅผ ๋ง๋ค๋ฉด(์์ฃผ ๊ฐ๋จํ๊ฒ, ๋ฆฌํธ๋ฆฌ๋ฒ ๋๊ตฌ๋ก ๋ฌด์ฅํ ์์ด์ ํธ) ์ด ๋ ๊ฐ์ง ๋ฌธ์ ๋ฅผ ๋ชจ๋ ์ํํ ์ ์์ต๋๋ค!
- โ ์ฟผ๋ฆฌ ์์ฒด๋ฅผ ๊ณต์ํํฉ๋๋ค(์ฟผ๋ฆฌ ์ฌ๊ตฌ์ฑ).
- โ ํ์ํ ๊ฒฝ์ฐ ๋ค์ ๊ฒ์ํ ์ฝํ ์ธ ๋นํ(์์ฒด ์ฟผ๋ฆฌ)Critique the content to re-retrieve if needed (self-query)
์ด ์์ด์ ํธ ์ค์ ์ด ๊ฒฐ๊ณผ๋ฅผ ์ผ๋ง๋ ๊ฐ์ ํฉ๋๊น? ์๋ฆฌ์ฑ ์ Llama-3-70B๋ฅผ ์ฌ์ฉํ๋ LLM-as-a-judge์ ํ๊ฐ ๋ถ๋ถ์ ์ถ๊ฐํ์ต๋๋ค. ๋ฐ๋๋ผ์์ ์์ด์ ํธ RAG๋ก ์ ํํ๋ฉด ์ ์๊ฐ 8.5% ์ฆ๊ฐํฉ๋๋ค! ๐ช (70.0%์์ 78.5%๋ก)
ํ์ง๋ง ํ ๊ฐ์ง ์ค์ํ ๋จ์ ์, ์์คํ ์ด 1์ด ์๋ ์ฌ๋ฌ LLM ํธ์ถ์ ํ๊ธฐ ๋๋ฌธ์ RAG ์์คํ ์ ๋ฐํ์๋ ์ฆ๊ฐํ๋ค๋ ๊ฒ์ ๋๋ค. ์ ์ ํ ์ ์ถฉ์์ ์ฐพ์์ผ ํฉ๋๋ค!