----------------------
Certainly! Composable Indices within the llama-index library allow you to build more complex and powerful index structures by combining multiple indices. Here are a few good use cases:
- Synthesis over Heterogeneous Data: LlamaIndex supports synthesizing across heterogeneous data sources by composing a list index over your subindices. This allows you to combine information from different data sources and query them together. Source (https://gpt-index.readthedocs.io/en/latest/use_cases/queries.html)
from llama_index import GPTSimpleVectorIndex, GPTListIndex
from llama_index.indices.composability import ComposableGraph
index1 = GPTSimpleVectorIndex.from_documents(notion_docs)
index2 = GPTSimpleVectorIndex.from_documents(slack_docs)
graph = ComposableGraph.from_indices(GPTListIndex, [index1, index2], index_summaries=["summary1", "summary2"])
response = graph.query("<query_str>", mode="recursive", query_configs=...)
- Routing over Heterogeneous Data: LlamaIndex also supports routing over heterogeneous data sources, allowing you to route a query to an underlying Document or a subindex. You can use
GPTTreeIndex
, GPTKeywordTableIndex
, or a GPTVectorStoreIndex
for this purpose. Source (https://gpt-index.readthedocs.io/en/latest/use_cases/queries.html)
from llama_index import GPTTreeIndex, GPTSimpleVectorIndex
from llama_index.indices.composability import ComposableGraph
# subindices
index1 = GPTSimpleVectorIndex.from_documents(notion_docs)
index2 = GPTSimpleVectorIndex.from_documents(slack_docs)
# tree index for routing
tree_index = ComposableGraph.from_indices(
GPTTreeIndex,
[index1, index2],
index_summaries=["summary1", "summary2"]
)
response = tree_index.query(
"In Notion, give me a summary of the product roadmap.",
mode="recursive",
query_configs=...
)