Find answers from the community

Updated 2 months ago

We are using pgvector and when

We are using pgvector and when retreiving results from database for user query , I see that we are limiting nodes to 2 , Is there any reason why we are harcoding 2 as limit ?
Plain Text
1749450564,-0.016525879502296448]'
     LIMIT 2
T
L
n
6 comments
Do you have it set in your script or do you wish to change it?
The vector index has a default top k of 2, but you can change this.

index.as_query_engine(similarity_top_k=3)
Thanks @Logan M
So @Logan M What will be the difference in performance , recall etc.. when we change top_k ? Any suggestions/ best practices around this topic
Top-k increases the number of document sent to the LLM. But this can both a) increase latency and b) sometimes increase hallucination if too many documents are retrieved

One approach often used is, people might set a high top-k, and then use a reranker to filter back down to a smaller set of relevant documents
Thanks @Logan M You are awesome !! Always helpful !!
Add a reply
Sign up and join the conversation on Discord