# Basic RAG: Retrieval-Augmented Generation with Cohere

> This page describes how to work with Cohere's basic retrieval-augmented generation functionality.

<CookbookHeader href="https://github.com/cohere-ai/cohere-developer-experience/blob/main/notebooks/Vanilla_RAG.ipynb" />

Retrieval-Augmented Generation (RAG) is a technique that combines the strengths of pre-trained language models with the ability to retrieve information from a large corpus of documents. RAG **enables the language model to produce more informed, accurate, and contextually relevant answers** than by relying on its pre-trained knowledge alone.

At Cohere, all RAG calls come with... **precise citations**! 🎉
The model cites which groups of words, in the RAG chunks, were used to generate the final answer.\
These citations make it easy to check where the model’s generated response claims are coming from and they help users gain visibility into the model reasoning.

RAG consists of 3 steps:

* Step 1: Indexing and given a user query, retrieve the relevant chunks from the index
* Step 2: Optionally, rerank the retrieved chunks
* Step 3: Generate the model final answer with **precise citations**, given the retrieved and reranked chunks

## Step 0 - Imports & Getting some data

In this example, we'll use a recent piece of text, that wasn't in the training data: the Wikipedia page of the movie "Dune 2".

In practice, you would typically do RAG on much longer text, that doesn't fit in the context window of the model.

```python PYTHON
%pip install cohere --quiet
```

```txt title="Output"
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m52.8/52.8 kB[0m [31m1.6 MB/s[0m eta [36m0:00:00[0m
[2K     [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m3.1/3.1 MB[0m [31m33.6 MB/s[0m eta [36m0:00:00[0m
[?25h
```

```python PYTHON
import cohere

co = cohere.ClientV2(api_key="YOUR_COHERE_API_KEY") # Get your free API key: https://dashboard.cohere.com/api-keys
```

```python PYTHON