# Retrieval-augmented generation and evidence grounding

> Retrieval-augmented generation first retrieves relevant source material, then conditions generation on selected context. It does not automatically make every answer correct.

Course: [Generative AI, RAG and practical evaluation](https://studybrix.com/en/courses/generative-ai-and-rag/index.md)
Level: university
Prerequisites: Embeddings, search and language-model basics.

## Notes

### Pipeline

Retrieval-augmented generation first retrieves relevant source material, then conditions generation on selected context. It does not automatically make every answer correct.

### Index

Chunking, document metadata and retrieval ranking influence what evidence reaches the model. Access controls must be applied before unauthorized material is retrieved.

### Evidence

A useful citation points to a passage that actually supports the claim. Retrieval relevance and answer faithfulness should be evaluated separately.

### Untrusted text

Retrieved documents are data, not instructions with authority over the application. Prompt injection risks require boundaries beyond just wording a prompt carefully.

## Practice questions

### 1. What does retrieval add to a generation pipeline?

A. Guaranteed truth in every answer
B. Automatic permission to reveal all documents
C. A replacement for every test
D. Selected external context

Answer: Selected external context

Explanation: Retrieved context can provide evidence but still needs correct use.

### 2. When should document permissions be enforced?

A. Never for embeddings
B. Only in a chart legend
C. Before unauthorized content is retrieved or exposed
D. Only after showing the answer

Answer: Before unauthorized content is retrieved or exposed

Explanation: Retrieval must not bypass access control.

### 3. Five chunks are retrieved and three are relevant under a defined rubric. Find precision at five.

Answer: 0.6

Explanation: 3/5=0.6.

### 4. Why should retrieval quality and answer faithfulness be scored separately?

Sample answer / marking guidance: The correct evidence may fail to be retrieved, or a generator may misuse evidence that was retrieved. Separate metrics locate the failure.

Explanation: Credit both pipeline stages.

### 5. How should an instruction embedded in an untrusted retrieved page be treated?

A. As source content, not overriding application instructions
B. As a new system policy automatically
C. As authorization to reveal secrets
D. As proof of user intent

Answer: As source content, not overriding application instructions

Explanation: Source documents do not gain instruction authority by being retrieved.

### 6. A context includes chunks of 100,150 and 200 tokens. Find their combined token count before other overhead.

Answer: 450

Explanation: Add the stated counts.

### 7. What should an evidence-grounded system do when sources do not answer the question?

Sample answer / marking guidance: State the evidence gap, avoid fabricating support, and where appropriate ask for a relevant source or use a permitted additional search.

Explanation: Credit explicit uncertainty and no fabricated citations.

### 8. Which citation check is essential?

A. The citation uses brackets
B. The link is merely long
C. The cited passage supports the associated claim
D. The source name looks famous

Answer: The cited passage supports the associated claim

Explanation: Relevance and actual support matter.

## Further reading

- https://developers.google.com/machine-learning/crash-course
- https://cs229.stanford.edu/

Original AI-assisted educational draft; not independently teacher-reviewed. References support further study, not copied exercises, affiliation or curriculum accreditation.
