azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

What variables should I change to change the number of retrieved search results.

Open suma-sai-paluri opened this issue 1 year ago • 4 comments
trafficstars

Minimal steps to reproduce

I want to retrieve 5 search results for every query made. How can I change the number in the code apart from changing the number it in the UI. I have tried changing at multiple place in the source code , but wasn't able to retrieve more than set 3 . And also is there a way to dynamically decide the number of search results based on the query ,because it would be helpful when we have a lot of documents. Thank you in advance

Mention any other details that might be useful


Thanks! We'll be in touch soon.

suma-sai-paluri avatar Dec 05 '23 18:12 suma-sai-paluri

Have you tried changing this line?

https://github.com/Azure-Samples/azure-search-openai-demo/blob/a1170562395ad122d2be0e8e29d33cac7ff169c2/app/backend/approaches/chatreadretrieveread.py#L121

To:

top = 10 or some other number?

In terms of dynamically deciding search results based on query, you'd need to change it in that function. I'm not sure what criteria you're using it for changing it, but you could try changing the function call to have a second parameter for number of sources, and then modify the query prompt few shots to demonstrate when it'd call different numbers of sources:

https://github.com/Azure-Samples/azure-search-openai-demo/blob/a1170562395ad122d2be0e8e29d33cac7ff169c2/app/backend/approaches/chatreadretrieveread.py#L132

pamelafox avatar Dec 06 '23 18:12 pamelafox

Hi @pamelafox I have tried making the changes in the following line of code: top = overrides.get("top", 3) but the changes are not being reflected. Do you think I should change else where , as of now I am able to control the number of document from the visual interface of the application only. In the case of dynamically deciding the search results, I am still trying to figure it out. If you have any repos that are using functions or any of these properties would be of great help. Thanks in advance

suma-sai-paluri avatar Dec 14 '23 09:12 suma-sai-paluri

any update on this issue ?

mahzy avatar Feb 12 '24 14:02 mahzy

Ah, sorry! You actually need to change it in the frontend, in Chat.tsx:

https://github.com/Azure-Samples/azure-search-openai-demo/blob/29355ec72e78404b3f1ad473a0695f8ff930226e/app/frontend/src/pages/chat/Chat.tsx#L36

That's because the frontend sends top to the backend here:

https://github.com/Azure-Samples/azure-search-openai-demo/blob/29355ec72e78404b3f1ad473a0695f8ff930226e/app/frontend/src/pages/chat/Chat.tsx#L148

If you removed that line above, then the modification to the Python code should work. But assuming you're keeping "Developer settings" around in the frontend, you should change the default there. Sorry for the confusion!

pamelafox avatar Feb 12 '24 20:02 pamelafox