Find answers from the community

Updated 3 months ago

Retriever

hey,
I went through CustomRetriever for utilizing it as one shot selector for selecting b/w different query index. Have gone through Query Transformations, but it seems to be a mechanism of converting a query into different query(s) for better search.
but how do we define one shot selector type llama_index inside _retrieve method.
the method for selecting nodes in CustomRetriever seems to be rule based for and and or operation but not intelliget selector
Plain Text
        if self._mode == "AND":
            retrieve_ids = vector_ids.intersection(keyword_ids)
        else:
            retrieve_ids = vector_ids.union(keyword_ids)

very confused here, please help
cc:
L
S
j
3 comments
The custom retriever there is just an example, you can do whatever you want inside of it πŸ’ͺ

I'm not sure what your use case is, but you might find more use out of the router abstraction https://colab.research.google.com/drive/1KH8XtRiO5spa8CT7UrXN54IWdZk3DDxl#scrollTo=a8bc0d20-fa6a-455b-ab85-ea9e4fcc0b37
gone through the notebook and found it was about creating a collection of index.queries() (index.query() can be wrapped under TransformQueryEngine ), the collection also contains the description of the query function.

then we can create RouterQueryEngine over all the collection of query functions along with a LLMSingleSelector (which according to me helps in selecting a single tool)

got this much and found that it will help in our use case, thanks

but still did not find any relevance of CustomRetriever with _retrieve() method to serve our use case.

our use case is to have 3 query tools
  1. answer from company doc
  2. answer from fixed docs
  3. answer directly from open ai without any context.
we can use RouterQueryEngine with a LLMSingleSelector for 1 and 2
but still did not get how to CustomRetriever with _retrieve() will be utilized in our usecase
@Logan M @ravitheja @jerryjliu0
Hey @Siddhant Saurabh , the custom retriever is just an example of how you can customize retrieval if you find that our default query engines/retrievers/indices aren't good enough. If they are good enough (e.g. if the router query engine works well), then great!

But otherwise the point is just that you can write your own retrieval logic and still plug it in if you'd like πŸ™‚
Add a reply
Sign up and join the conversation on Discord