llama_index icon indicating copy to clipboard operation
llama_index copied to clipboard

[0.5.0] Composability

Open Disiok opened this issue 1 year ago • 0 comments

composability (1)

Conceptual changes

  • Decouple index structure and data

V2IndexStruct is no longer a BaseDocument.

  • We introduce CompositeIndexStruct to model a composed graph

This makes ComposableGraph is very similar to BaseGPTIndex. We could unify this further later.

  • Model relationship between indices via IndexNode

IndexNode is a Node with a pointer to an IndexStruct
We no longer "set_text" on a IndexStruct, which breaks various abstractions. The same can be expressed as creating an IndexNode with some summary text, and point it to the IndexStruct.

Storage

  • We use DocumentStore to store data (i.e. Document and Node)

This eliminates many ugly "if this is an index struct, do X, otherwise do Y" logic.

  • We save V2IndexStruct separately

To support saving and loading polymorphic objects, we always save its type along with the actual object

Querying

  • Remove recursive logic from BaseGPTIndexQuery

Now recursive logic is entirely managed via QueryRunner. This removes mutual recursion and make things easier to reason about.

  • Introduce def retrieve and def synthesize API

This makes it explicit which queries support recursive call vs. not.

Misc Change (WIP)

  • group common params into ServiceContext object

We basically pass these around across all data objects. This is mostly an attempt to make code cleaner.

Todos

  • [ ] Figure out how to deal with query type to query map
  • [ ] Fix composability for tree
  • [ ] Fix query combiner support
  • [ ] Lint and tests
  • [ ] Clean up BaseGPTIndexQuery ctor mess

Disiok avatar Mar 25 '23 21:03 Disiok