Three ways to give an LLM your knowledge
There are several approaches to make an LLM "know" your data: put it all in the context (prompt), fine-tune the model, or use RAG. Each has its place. Understanding when to use what is an important engineering decision. Let us cover the differences.
Three approaches
- All in context: insert the needed data directly into the prompt. Simple, but the data must be small (context limit), and costly to repeat a large context each time.
- Fine-tuning: fine-tune the model on your data. Good for style and behavior, but costly, hard to update, and the model still tends to invent facts.
- RAG: find the relevant in your data and feed it into the context dynamically. Good for working with extensive, changing data on facts.
A common misconception: "must fine-tune"
A common beginner mistake is thinking that "answers over our documents" needs fine-tuning the model. Usually no. Fine-tuning is good for style and behavior but poor for remembering facts (the model still invents, and updating is costly). For factual answers over your data RAG is almost always better: cheaper, easily updated (just change the data), gives source citations, hallucinates less. Do not rush to fine-tune where RAG is needed.
RAGs strengths
RAG is especially good when: there is a lot of data (does not fit in context), it changes (updated ā RAG uses the new at once), accurate factual answers are needed, source citations are needed (important for trust ā you can show where the answer came from). That is why RAG is the standard solution for knowledge-base assistants, document support, internal-data search. Later in the course ā how to build it.
Rule: little data to context; a lot of changing data with facts and citations needed to RAG; change style/behavior to fine-tuning. For "answers over our data" you usually need RAG, not fine-tuning.
š§ What is usually needed for "answers over our documents"?