4 Augmenting LLMs with your own documents

 

In this chapter

  • You learn how Retrieval-Augmented Generation (RAG) works.
  • You acquire a methodology for designing the right RAG setup for your specific needs and documents.
  • You build and optimize RAG flows using Langflow components.

Our magic black box seems to have deep knowledge, but it’s… generic. When LLMs are pre-trained, they learn from a plethora of generic documents. As a consequence, their answers are typically based on general common sense. They tend to reflect an “average” of all that can be said on a specific topic (and they combine a lot of what has been generically said about that topic).

But is this always what we need? What if we want our GenAI assistant to answer questions about—let’s say—the opening hours of our small ice cream shop?

Is a generalist assistant able to help us in all cases? Not always, and here are a few reasons why:

RAG in a nutshell

Document ingestion

Document retrieval

Answer generation

Building a RAG system in Langflow

Document ingestion

Retrieve and answer

Taking RAG to the next level

Chunk and overlap size matter

The number of top documents matters

Grab the text of webpages

Read multiple files at once

Optimize your search query

Use metadata in RAG

Summary