Find answers from the community

Updated 3 months ago

Responses

In the following code
Plain Text
def load_index():
    # index if dir 'storage' does not exist
    if not os.path.exists('storage'):
        print('Building index...')
        build_index()
    storage_context = StorageContext.from_defaults(persist_dir='./storage')
    # doc_hash_to_filename = json.load(open('doc_hash_to_filename.json', 'r'))
    return load_index_from_storage(storage_context)

def ask_question(index, query):
    query_engine = index.as_query_engine()
    response = query_engine.query(query)
    return response

I always get 2 responses right now, for any query. How can I get more? is there a parameter I can change?

I also posted this on Stack Overflow and as an issue on the repository - please let me know if there is an answer.
L
k
6 comments
Do you mean you only get two source nodes?
You can increase that when creating the query engine

index.as_query_engine(similarity_top_k=3)
thank you so much!! can you tell me where i see this in the documentation. i kept on looking but i clearly dk how to look!
Quite a few places in the docs, but i agree it's never addressed clearly it seems ๐Ÿ˜…

https://gpt-index.readthedocs.io/en/latest/search.html?q=similarity_top_k&check_keywords=yes&area=default
Thank you Logan!
Add a reply
Sign up and join the conversation on Discord