in simple words, not from scientific article.
RAG is a prompt.
You just look for some content, anywhere around, and use it as prompt. That’s it. RAG.
You must find content to improve your own prompt with RAG prompt.
You can use text documents, images, websites, PDFs… Anything with textual information. For image, you need to use image-to-text deep learning model to find what is in the image.
For text, you can use it directly, just adding it to your prompt.
Sometimes a simple RAG prompt is too big. Let’s say we want to ask AI about a book. Obviously, you cannot use the whole book as a prompt. AI will cut or rather truncate it.
So, you can cut the book yourself into chunks. Then you have to find the chunk which is most relevant to your question.
Lets use Alice in Wonderland. You will cut it into chunks, using some method. We will talk about how to cut later.
So, you have asked a question – who smiled in the book. You find a few chunks, where smile was mentioned, use them as RAG prompt, use system prompt which says something like “use this RAG prompt to answer question” and ask your question. In the selected chunks there will be probably Cheshire cat who smiles. AI will happily answer that in the book, Cheshire cat smiles. RAG worked.
Now, you can search for relevant chunks in few ways, you can even preprocess each chunk using AI prompt asking to summarize or/and tag the chunk (contextual RAG)
You can use different methods to cut text into chunks. Python langchain library, a Swiss Army knife of language model has many methods to cut, search for relevant chunks and lots of other tools. If chapters are well sized, you can use them to cut.
I hope you got a good read. Tomorrow I will use this blog post as RAG chunk and ask ChatGPT some tough questions.
Pingback: what is RAG part 2 - moonytunes