概念
Retrieval Augmented Generation (RAG)
Look up facts first, add them to the prompt, then let the model answer from them.
本课尚未翻译,暂以英文显示。
- 1The user question is turned into an embedding and searched in the vector store.
- 2The best matching passages come back.
- 3The passages are added to the prompt with the question.
- 4The foundation model writes an answer grounded in those passages.
分步说明
- 1The user question is turned into an embedding and searched in the vector store.
- 2The best matching passages come back.
- 3The passages are added to the prompt with the question.
- 4The foundation model writes an answer grounded in those passages.
RAG: the question finds passages, which join the prompt.
Customer support bot
- Answers from the product manuals
Company search
- Ask a question, get the policy page
HR and policy help
- Staff ask about leave rules
Document assistant
- Answers with source links
| Use | Example |
|---|---|
| Customer support bot | Answers from the product manuals |
| Company search | Ask a question, get the policy page |
| HR and policy help | Staff ask about leave rules |
| Document assistant | Answers with source links |
是什么
A foundation model only knows what it saw in training. It does not know your private documents or this morning's news, and it can invent answers. Retrieval Augmented Generation (RAG) fixes this without changing the model.
RAG works in three moves. First, retrieve: the question is turned into an embedding and used to search a vector store that holds your documents. Second, augment: the best matching passages are added to the prompt. Third, generate: the model writes an answer from those passages. The answer is grounded in your data, and the app can show the sources.
是什么
RAG is a good first choice when facts change often or are private. To update knowledge, you update the documents. You do not retrain anything.
要记住
- RAG = retrieve relevant data, add it to the prompt, generate a grounded answer.
- It uses embeddings and a vector store to find passages by meaning.
- It gives the model current and private knowledge without retraining.
- Grounding in real documents reduces hallucinations and allows source citations.
要记住
- To change the knowledge, change the documents.
- Amazon Bedrock Knowledge Bases is the managed way to do RAG on AWS.
考试中
- “Answer questions using the company's own documents, without retraining” points to RAG.
- “Reduce hallucinations by grounding answers in trusted data” points to RAG.
- “Fully managed RAG on AWS” points to Amazon Bedrock Knowledge Bases.
别和这些弄混
- Amazon Bedrock Knowledge BasesManaged RAG: Bedrock reads your documents, stores them as vectors and retrieves them for the model.
- Fine-tuning methodsWays to adapt a pre-trained model: instruction tuning, domain adaptation, transfer learning and continued pre-training.
- Hallucination detection and groundingMake a model’s answers match real sources, and catch the ones that do not.