Understanding the basic retrievers
Retrieval mechanisms are a central element in any RAG system. Although they work in different ways, all types of retrievers are based on the same principle: they browse an index and select the relevant nodes to build the necessary context. Each index type offers several retrieval modes, each providing different features and customization options. Regardless of the retriever type, the result that will be returned is in the form of a NodeWithScore
object – a structure that combines a node with an associated score. The score can be useful further in the RAG flow because it allows us to sort the returned nodes according to their relevance. However, keep in mind that while all retrievers return NodeWithScore
, not all of them associate a specific node score.
As usual, LlamaIndex offers multiple alternatives to accomplish a task, so a retriever can be constructed in several ways. The simplest path is direct construction from an Index
object. Assuming...