Building Indexes on top of other Indexes with ComposableGraph
The ComposableGraph
in LlamaIndex represents a sophisticated way to structure information by stacking Indexes on top of each other.
Figure 5.12 provides an overview of a ComposableGraph
:
Figure 5.12 – The structure of a ComposableGraph
This approach allows for the construction of Indexes within individual documents – lower-level Indexes – and the aggregation of these Indexes into higher-order ones over a collection of documents. For example, you can build a TreeIndex
for the text within each document and a SummaryIndex
that encompasses each TreeIndex
in a collection.
How to use the ComposableGraph
Here’s a simple code example demonstrating the usage of ComposableGraph
:
from llama_index.core import ( ComposableGraph, SimpleDirectoryReader, TreeIndex, SummaryIndex) documents = SimpleDirectoryReader("files...