llama_index icon indicating copy to clipboard operation
llama_index copied to clipboard

Looking for 'Ref-Query', to learn about query_kwargs

Open zmrubin opened this issue 1 year ago • 5 comments

Hi! first of all, thanks for a really cool open source project!

I've been working on getting up to speed, and am now trying to put together a text summary with a custom template.

response = index.query("What is a summary of this collection of text?", response_mode='tree_summarize', text_qa_template = SUMMARY_PROMPT)

I believe 'text_qa_template' should be something like 'text_summary_template' ; but I'm not able to find a list or docs on the available query_kwargs for the tree_summarize mode option (or others for that matter)

Digging in, i was able to get as far as this note:

For a comprehensive documentation of available `mode` and `query_kwargs` to
        query a given index, please visit :ref:`Ref-Query`.

But couldn't find the Ref-Query referenced there

Thanks for the help!

-Z

https://github.com/jerryjliu/gpt_index/blob/ab736bd0e607312a9a34ac1f64e97597c1942837/gpt_index/indices/tree/base.py#L38

zmrubin avatar Mar 09 '23 13:03 zmrubin

hi @zmrubin, this is part of our sphinx autogenerated docs. You can find the link here: https://gpt-index.readthedocs.io/en/latest/reference/indices.html#gpt_index.indices.base.BaseGPTIndex

jerryjliu avatar Mar 09 '23 20:03 jerryjliu

Ok got it;

Is there a kwargs summary alternative to text_qa_template ? \

Once I have the SummaryPrompt , i need to pass it to index.query() as a different kwarg (not text_qa_template) . Been looking all over in the docs and haven't been able to find info in this.

thanks in advance

zmrubin avatar Mar 09 '23 23:03 zmrubin

Hi @jerryjliu help really appreciated on this one! sorry to bug. Probably a simple answer, I just have not been able to find it in the Docs, or source code.

If index.query() support for SummaryPrompt templates is not yet supported, maybe i could build it and open up a PR. Would need a bit of guidance before digging into that though

zmrubin avatar Mar 13 '23 22:03 zmrubin

Sorry, could you explain more why need to pass it in as something other thantext_qa_template?

AFAIK, text_qa_template is the correct arg to customize the query template, i.e. you should define a subclass of QuestionAnswerPrompt with context_str, query_str as input variables.

Disiok avatar Mar 18 '23 17:03 Disiok

But I do agree that our custom prompt support is a bit confusing 😅. Would love to see some contribution on this front. Happy to help review any PR!

Disiok avatar Mar 18 '23 17:03 Disiok

@Disiok actually, @zmrubin is correct, we don't currently expose the summary prompt template for things like tree_summarize

A PR for this would be very cool!

logan-markewich avatar Jun 05 '23 15:06 logan-markewich