Building a simple chatbot is a great start, but as you've noticed, it has some serious limitations. The biggest one? The model's knowledge is static and incomplete.
This is a major problem for two main reasons:
Private Data: Large Language Models (LLMs) are only trained on publicly available information. They have no access to your company's internal documents, private databases, or any other information that isn't on the public internet. If you ask a simple chatbot a question about your private data, it won't have a clue what you're talking about.Knowledge Cutoff: The training process for an LLM is incredibly long and expensive, taking months or even years. This means the model's knowledge is "cut off" at a specific date. Any event, discovery, or change that happened after that date is something the model simply doesn't know about.This means it confidently generates a response that sounds plausible but is completely made up and factually incorrect. It's not malicious; the model is just trying its best to be helpful by predicting the most likely words in a sequence based on its training data, even if it has no real knowledge to back them up.
Simply changing your prompt won't fix this either. No matter how you rephrase the question, the model is still limited to the same outdated and incomplete knowledge it was originally trained on. You need a way to give the model access to new, external information

If you only had one or two pages of private or new information for your AI, this would be easy. You could just copy and paste the entire text into every single prompt you send to the model.
But what if you have hundreds or thousands of documents? That’s where the main challenge lies. You have far more information than can fit into a single prompt.
So, how do you solve this "quantity problem"? How do you pick the small, crucial pieces of information from your massive collection of text to help the LLM answer a specific question?
The solution involves a two-step process, which is the foundation of Retrieval-Augmented Generation (RAG):
This chapter focuses on the first step: indexing. Before we dive into the "how," let's explore why your documents need to be preprocessed in the first place. Before we dive into the "how," let's explore why your documents need to be preprocessed in the first place. Let’s assume you would like to use LLMs to analyze the financial performance and risks in Tesla’s 2022 annual report https://www.sec.gov/Archives/edgar/data/1318605/000095017023001409/tsla-20221231.htm , which is stored as text in PDF format. Your goal is to be able to ask a question like “What key risks did Tesla face in 2022?” and get a humanlike response based on context from the risk factors section of the document. Breaking it down, there are four key steps (shown in Figure 2-1) that you’d need to take in order to achieve this goal: