Find answers from the community

Updated 2 months ago

Hello I am currently experimenting with

Hello! I am currently experimenting with Decompose query transform on a graph structure (a vector index of vectors subindices). However, the current DEFAULT_DECOMPOSE_QUERY_TRANSFORM_TMP doesnt seem to accurately decompose my original query. Is it possible for a me to create/edit the DEFAULT_DECOMPOSE_QUERY_TRANSFORM_TMP without breaking the current code?
L
k
15 comments
In the constructor, you can pass in decompose_query_prompt with your own template:
https://github.com/jerryjliu/llama_index/blob/main/gpt_index/indices/query/query_transform/base.py#L139

I think you already found it, but you can see how to create your own template by following the original: https://github.com/jerryjliu/llama_index/blob/main/gpt_index/indices/query/query_transform/prompts.py
Great and also I just wanted to check if this feature is working as expected? This is my query config.

# number of graph nodes to retrieve during query. USer defined. Take into account the cost, performance and
# speed tradeoff.
num_graph_nodes_to_retreive = 2

#number of sub indices within a graph node to retrive during query
num_sub_indices_to_retreive = 1

# the query config allows us to define the strategy for querying
query_configs = [
# this config is for the graph structure
{ "index_struct_id": "graph",
"index_struct_type": "simple_dict",
"query_mode": "default",
"query_kwargs": {
"similarity_top_k": num_graph_nodes_to_retreive,

},
# NOTE: set query transform for subindices
"query_transform": decompose_transform

},

# this config is for the sub indices
{

"index_struct_type": "simple_dict",
"query_mode": "default",
"query_kwargs": {
"similarity_top_k": num_sub_indices_to_retreive,

}

},
]
Here does the DEFAULT_DECOMPOSE_QUERY_TRANSFORM_TMP give the graph node summary as context first? So in this case llama-index will first take two graoh nodes, use that context to generate a new query using DEFAULT_DECOMPOSE_QUERY_TRANSFORM_TMP and then use that new query to interrogate the subindices within those nodes?
Because that is what I intent to do here and just wondering how can I replicate it with llama-index
I thiiiink you want the query_transform on the sub indices? At least, that's what the original guide does (I haven't had a chance to play around with it too much yet lol)

Maybe try both ways and see which performs better lol
Thanks ill give it a go
I just tried putting "query_transform": decompose_transform on both the query configs and it works as I expected it to!
Nice! πŸ’ͺ
Hi @Logan M ! Sorry to bother again lol
I think I found class DecomposeQueryTransform(BaseQueryTransform) that performs the query decomposition
From this (I am not sure if I am reading it correctly) is the context being pulled from the summary metadata associated with an index?
Could you kindly confirm where the DEFAULT_DECOMPOSE_QUERY_TRANSFORM_TMP is pulling the context from?
Yes, it looks like you are right from what I can see
Add a reply
Sign up and join the conversation on Discord