Skip to main content

Basic

Data Retrieval is a key step in any RAG application. The most common use case is to retrieve relevant context from your data to help with a question.

Once data has been ingested into LlamaCloud, you can use the Retrieval API to retrieve relevant context from your data.

Our Retrieval API allows you to retrieve relevant ground truth text chunks that have been ingested into a Index for a given query. The following snippets show how to run this basic form of retrieval:

import os

os.environ[
"LLAMA_CLOUD_API_KEY"
] = "llx-..." # can provide API-key in env or in the constructor later on

from llama_index.indices.managed.llama_cloud import LlamaCloudIndex

# connect to existing index
index = LlamaCloudIndex("my_first_index", project_name="Default")

# configure retriever
retriever = index.as_retriever(
dense_similarity_top_k=3,
enable_reranking=False,
)
nodes = retriever.retrieve("Example query")

We can build upon this basic form of retrieval by including things like hybrid search, reranking, and metadata filtering to improve the accuracy of the retrieval. These advanced retrieval parameters are described in greater detail in the next section ➡️