Find answers from the community

s
F
Y
a
P
Updated 2 years ago

Prompts

When we write a prompts for example,
Plain Text
DEFAULT_REFINE_PROMPT_TMPL = (
    "The original question is as follows: {query_str}\n"
    "We have provided an existing answer: {existing_answer}\n"
    "We have the opportunity to refine the existing answer "
    "(only if needed) with some more context below.\n"
    "------------\n"
    "{context_msg}\n"
    "------------\n"
    "Given the new context, refine the original answer to better "
    "answer the question. "
    "If the context isn't useful, return the original answer."
)

How can I give my VectorStoreIndex information as a context_msg?
L
s
15 comments
context_msg gets filled in at query time, with the text from the current node being used to refine an answer πŸ‘
Thanks! I have another question.

Do you have any recommendations for the Index object when correcting the given query? In my opinion, since VectorIndex uses cosine similarity, there could be some problems. For example, if the query is "Requirements: Full code base" and the context_str is "Requirements should be listed with priorities," I would like to correct it as something like "Requirements1: ..., Requirements2: ..."
Or should I use more specific custom QA prompt?
Hmm, I think I'm maybe misunderstanding. You want to query an index and have it return a list of prioritized requirements?

The context_str/msg comes from the actual documents in your index. So you could modify the prompt template so that it better returns in the format you need πŸ‘
Oh, sorry for the bad explanation, what I meant was, if the query is "Correct this sentence: {query_str}", I want it to refer to the Index.
I'm getting confused....sorry...:(
What I want to do is correct the given sentence with the rule or reference in a given document.
I stored the document with the VectorIndex. I can't get desirable response. So I'm wondering what should I do.
Interesting use case!

Yea, I would write a custom qa and refine template for sure

You'll want to say something in your template like "....... Given the context above, correct the given sentence: {query_str}"

Might have to get a little creative πŸ™‚
Thanks! Do you think that I don't have to use another Index Structures, like Keyword Table or something?
I think a vector index is fine for now! You can try increasing similarity_top_k in the query to retrieve more matching nodes.

A keyword index will use all the nodes that have keywords matching the keywords extracted from the query.

A list index will check every node in your index.

So, I guess it's up to you which index sounds better. It might take some experimenting
When indexing vector indices, we read some chunks of the document's text, so it can be quite different from the reading whole pdf.

So it can cause a problem since sometimes the continuous contents of a documents are break down into different chunk, am I right?

In that case, configuring overlapping parameter can be helpful, I think.
Hope I can get some awesome results and applications.
Thanks always πŸ˜„
You might also be interested in this recent feature, check out this Twitter thread https://twitter.com/jerryjliu0/status/1642908812771471360?cxt=HHwWgMDR-Yq35MwtAAAA

I haven't had a chance to try it, but it might be helpful! πŸ‘
Add a reply
Sign up and join the conversation on Discord