Course menuAIF-C01

Exams / AIF-C01 / Study guide / RAG, knowledge bases and vector stores

RAG, knowledge bases and vector stores: AIF-C01 study notes and practice questions

What to know about RAG, knowledge bases and vector stores for the AIF-C01 exam, from the Applications of Foundation Models domain (28% of the exam guide), then 4 free questions to test it. Part of the AIF-C01 study guide.

Last verified against current AWS documentation ·How we write our questions

What to know for the exam

RAG is one of the most tested ideas on the exam. Use it when answers must come from company documents that change, without retraining a model.

How RAG works

Preparing the data (once, then on updates):

  1. Split documents into chunks.
  2. Turn each chunk into an embedding with an embeddings model.
  3. Store the vectors in a vector store.

At question time:

  1. Embed the user’s question.
  2. Search the vector store for the most similar chunks.
  3. Add those chunks to the prompt.
  4. The foundation model generates an answer grounded in them, ideally with citations.

Amazon Bedrock Knowledge Bases

A managed RAG service: point it at your data (such as an S3 bucket), choose an embeddings model and a vector store, and it handles chunking, embedding, syncing and retrieval. Answers can include source citations.

Vector stores on AWS

  • Amazon OpenSearch Service (and OpenSearch Serverless)
  • Amazon Aurora PostgreSQL and Amazon RDS for PostgreSQL with the pgvector extension
  • Amazon S3 Vectors for low-cost vector storage
  • Amazon Neptune Analytics, Amazon DocumentDB, Amazon MemoryDB

RAG vs other approaches

Need Best fit
Answers from current company documents RAG
A different tone, format or specialized behavior Fine-tuning
Better answers from clearer instructions Prompt engineering

RAG is cheaper than fine-tuning, keeps data current by re-syncing, and reduces hallucinations because answers are tied to sources.

Common traps

  • Fine-tuning to add facts that change weekly. Use RAG.
  • Skipping chunking. Whole documents make poor search results and may not fit the context window.
  • Assuming RAG removes all hallucinations. It reduces them; add grounding checks and citations.

Try the 4 practice questions

A city council's resident help assistant uses Amazon Bedrock Knowledge Bases over policy documents that were already chunked, embedded and stored in a vector index.

Put these steps in the order they happen when a resident asks a question, first step first.

Put these 5 steps in order.

  1. A. The resident's question is converted into a vector by an embedding model
  2. B. The foundation model generates an answer from the augmented prompt
  3. C. The most similar chunks are returned as context for the prompt
  4. D. The vector index is searched for chunks similar to the question's vector
  5. E. The retrieved chunk text is added to the prompt before generation
Show the answer and explanation

Correct order: A, D, C, E, B

  1. A. The resident's question is converted into a vector by an embedding model First: the question must become a vector before it can be compared with the stored chunk vectors. The embedding model has to produce vectors that can be compared with the index.
  2. D. The vector index is searched for chunks similar to the question's vector Second: similarity search compares the question's vector with the document vectors in the index. It returns the chunks whose meaning is closest to the question.
  3. C. The most similar chunks are returned as context for the prompt Third: the chunks that matched the search are returned as the context that will ground the answer. Only the closest matches are passed on, not the whole document set.
  4. E. The retrieved chunk text is added to the prompt before generation Fourth: the user's prompt is augmented with the retrieved text, so the model answers from the council's documents. The model sees the question together with this supporting text.
  5. B. The foundation model generates an answer from the augmented prompt Fifth: generation happens last, once the prompt contains the retrieved context. The model then writes an answer grounded in the council's policy text.

Explanation

At query time a knowledge base embeds the question, searches the vector index for similar chunks, adds the retrieved text to the user's prompt, and has the foundation model generate the answer. Chunking and embedding happened earlier, when the documents were loaded.

Study

An airline's customer assistant must answer questions about baggage and refund rules.

The rules change most weeks, answers must cite the current policy text, and the airline does not want to retrain a model each time a rule changes.

Which approach fits BEST?

Choose one answer.

  1. A. Pre-train a new foundation model on the policy documents every week
  2. B. Use RAG over the policy documents to retrieve current text
  3. C. Raise the temperature so the model explores more possible policy answers
  4. D. Fine-tune the model once on last year's policy documents
Show the answer and explanation

Answer: B

  • A. Wrong: Pre-training builds a model from large datasets at high cost, and repeating it every week is impractical. It also does not give answers that cite the current policy text.
  • B. Right: Correct. Retrieval Augmented Generation fetches the current policy passages at query time, adds them to the prompt and can cite the source. Updating the documents updates the answers without retraining the model. Learn more: Amazon Bedrock Knowledge Bases (opens in a new tab)
  • C. Wrong: Temperature changes how random the output is. It cannot give the model knowledge of policy text it has never seen.
  • D. Wrong: A one-off fine-tune fixes last year's rules into the model, so it goes out of date as policies change. It also cannot cite the current text.

Explanation

Retrieval Augmented Generation grounds a model's answer in documents retrieved at query time. Amazon Bedrock Knowledge Bases indexes the policy documents, adds retrieved passages to the prompt, and can include citations in the response. Fine-tuning and pre-training store knowledge in the model's weights, which goes stale.

Retrieval augmented generation with a knowledge base Sync: documents from S3 and other connectors are split into chunks, turned into embeddings, and stored in a vector store. Query: a user question retrieves the best matching chunks from the vector store, and the model writes an answer from them with citations. Sync Documents S3, connectors Chunk + embed embeddings Vector store managed or own Query User question from the app Retrieve best chunks Model answers with citations
RAG retrieves the current policy text at question time, so answers follow the rules without retraining the model.

Study

A software company already runs Amazon Aurora PostgreSQL-Compatible Edition for its product catalog, and its database team knows it well.

A new RAG application needs embeddings stored and searched by similarity, and the company wants to avoid adopting a new database service.

Which option BEST meets these needs?

Choose one answer.

  1. A. Aurora PostgreSQL-Compatible Edition with the pgvector extension to store embeddings
  2. B. Amazon DynamoDB, with each embedding stored as a number list and retrieved by its partition key
  3. C. Aurora MySQL-Compatible Edition, with a full-text index built over the embedding text column
  4. D. Amazon S3, with each embedding saved as a separate JSON object in a bucket with versioning on
Show the answer and explanation

Answer: A

  • A. Right: Correct. Aurora PostgreSQL supports the pgvector extension, which stores vector embeddings and runs similarity search in the database the team already operates. This meets both the search need and the no-new-service constraint. Learn more: Amazon Aurora PostgreSQL now supports pgvector (opens in a new tab)
  • B. Wrong: Queries by partition key return exact key matches, not the nearest vectors. Similarity search would need extra design, and DynamoDB would be a new service for the team to learn.
  • C. Wrong: A full-text index finds documents that contain the query's words, not ones with similar meaning. It is not a vector search, so it would miss documents that express the same idea in different words.
  • D. Wrong: S3 stores objects durably but cannot search them by vector similarity. The application would have to load and compare the files itself.

Explanation

A vector store holds embeddings and finds the nearest ones to a query vector. Aurora PostgreSQL-Compatible Edition can do this with pgvector, so the team can keep its existing database and skills. Options that only store data or match keywords do not perform similarity search.

Study

A university loads 2,000 long research reports into a knowledge base. Each report is split into smaller chunks, and each chunk is converted to an embedding before it is stored in a vector index.

What is the main purpose of this chunking step?

Choose one answer.

  1. A. So each report can be stored in a different AWS Region for resilience
  2. B. So the foundation model is fine-tuned separately on each chunk of text
  3. C. So only the passages relevant to a question are retrieved and fit in the prompt
  4. D. So each chunk is encrypted separately before it is embedded
Show the answer and explanation

Answer: C

  • A. Wrong: Regional placement is set by where the data and index are deployed. Chunking is about how text is retrieved, so it does not decide where reports are stored.
  • B. Wrong: A knowledge base retrieves chunks and adds them to the prompt. It does not fine-tune the model, which is a separate customization method.
  • C. Right: Correct. Each chunk gets its own embedding, so a search can return the few passages that answer a question, and they fit in the model's context. The mapping back to the source document is kept for citations. Learn more: How Amazon Bedrock knowledge bases work (opens in a new tab)
  • D. Wrong: Encryption protects stored and transmitted data and is configured separately from chunking. Chunking does not change how the data is protected.

Explanation

Chunking splits documents into manageable pieces before they are embedded and written to a vector index. Each chunk gets its own vector, so a search returns specific passages rather than whole long reports. Each chunk keeps a mapping back to its source document.

Study

Want more on RAG, knowledge bases and vector stores? The 5 full-length practice sets have 20 more RAG, knowledge bases and vector stores questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets

Study RAG, knowledge bases and vector stores

More Applications of Foundation Models topics