nasirus / llama_index

MIT License
1 stars 0 forks source link

How can merge multi index file #8

Closed nasirus closed 1 year ago

nasirus commented 1 year ago

Hi,

For example I have 2 folder, folder 1 I use GPTTreeIndex and save to index1.json. And folder 2 I save to index2.json. So, now I want to load 2 index files. Ho can I do it?

nasirus commented 1 year ago

Answer: You can use the GPTListIndex to merge multiple indices. The GPTListIndex allows you to combine multiple GPTSimpleVectorIndex objects into a single index. Here is an example of how to do this:

from llama_index import GPTSimpleVectorIndex, GPTListIndex

index1 = GPTSimpleVectorIndex.load_from_disk('index1.json')
index2 = GPTSimpleVectorIndex.load_from_disk('index2.json')

merged_index = GPTListIndex([index1, index2])

You can then use the merged_index as you would any other index.

For more information, please see the GPTListIndex documentation.

Regards, The Llama Index Team