-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search Pipelines] Share state between multiple processors #6722
Comments
This is described more in opensearch-project/search-processor#80 |
I'd like to try to formalize some behavior, especially now that a) search pipelines are out, so we know exactly how request/response processors get configured, and b) we'd like to try to get bracket processors out soon. Balance and orderI still feel that we should enforce a rule saying bracket processors need to be balanced like a stack (like brackets or parentheses) -- that is, just as we can't say Explicit and implicit balancingBecause we may want to modify requests and responses with SearchRequestProcessors and SearchResponseProcessors before/after bracket processors act, we need a way of explicitly communicating when a given processor should run (as long as it doesn't violate the "reverse order" rule specified above). An example of that explicit ordering could be something like:
In this example, we're using a hypothetical request processor to increase the requested The I was also thinking that we might want to implicitly balance any bracket processors by closing any open brackets at the end of the chain of response processors. In the above example, if the bracket processor was not specified in the response processor chain, it would still be included at the end. You would need to explicitly reference it in the response processor chain if you want it to execute before some other response processor(s). Given that implicit balancing would be a convenience feature that supports a subset of explicit balancing behavior, we could leave that to a later release (i.e. the initial release would only support explicit balancing and would throw an exception if a bracket processor is not balanced). Implementation challenge: per-request processor stateRight now, search pipelines are created as a result of a PUT pipeline request (which writes to cluster state and that cluster state gets propagated to every data node, which listens for the cluster state update and creates the search pipeline object which is held in a So, how can we make a pipeline with stateful processors without changing everything? I think we can take advantage of the PipelinedRequest class that already combines a pipeline with a search request. I see a couple of possible solutions for propagating state:
I think the second option is easier to implement in OpenSearch core, but I feel like the first option might feel a little more natural for processor implementers (since the |
@msfroh E.g.
Then a search pipeline can look like this instead:
To make that work, we'll have to add some default methods to SearchRequestProcessor and SearchResponseProcessor:
I think it's counter-intuitive to have to put a bracket process in two places ("request_processors" and "response_processors"). On the question of state propagation, have you decided which option you want to proceed with? Are there any tasks that I can help with? |
Hi @msfroh , As per my understanding this is just more of convenience feature so that users are not making mistakes while building the query weighs less than adding states in simple and stateful api interface.(again this is just my thought) If possible can you add more use cases where having a stateful Search pipeline will be useful? |
@navneet1v One use case from conversational search is that we want to allow the request processor to re-write the query/question and have the re-written question be propagated to the response processor. The response processor now has both the question and the answer (from an LLM) that it can then store in (conversational) memory. Here, we want to think of what the request processor does and what the response processor does as one unit of work in RAG. This can be modeled using a |
If Search Pipeline States are there then I don't see why this cannot be done, by just creating 2 processors 1 Request Processor(Re-write Query/QuesProcessor) and another Response Processor(Saves info in Conversation memory). Users will have a flexibility to say whether they want to store their conversations or not.
(Just for reference, if you understand how search pipeline works please ignore this) |
This doesn't exist today, correct? I don't think you want any arbitrary request/response processor to have access to this state. What is being proposed is that this state be scoped to a single processor. Or are you referring to something that is already available to be able to pass state/context between processors? |
@austintlee
No this is not true. The proposal is state will be scoped at the Search Request Level. |
Thanks for the clarification. I am OK with that. Mainly, I wanted to get clarification that "something new needs to be done for state to be shared between search processors". |
So, I started to hack away at an implementation of "approach 2" where we have the state managed outside of the processors (essentially as a field of Now, the approach I'm working on is a On the flip side, if I made just made it a The catch of that approach is that it relies on users doing the right thing -- e.g. only add the response processor that reads some state if you've added the corresponding request processor that writes the state. |
I like it. It solves my problem :-) and it does not preclude introducing a new processor type later (if that turns out to be a useful thing someone wants). |
Okay -- I think I have something that essentially works in #9405. To avoid breaking backward compatibility with the existing stateless processors, I did some interface hackery to make it easy to say that you're creating a "stateful" request/response processor (though it's ultimately the same interface). I was previously planning to add an As written, you can't specify multiple OversampleRequestProcessors and truncate back to the original size (whereas that would have worked with the bracket processor). Of course, we could fix that by adding a config parameter to the stateful processors -- something like
|
@msfroh what is the next step on that PR? It's still in draft status. |
@macohen - Hi Mark, Can you please enter a doc issue if this needs documentation? Also, please confirm that it is going in 2.11. Thanks! |
@hdhalter moving this to a 2.12 release will update the doc issue as well. |
@msfroh please feel free to close it but we need the documentation update as well for this feature |
@msfroh will this be ready for a 2.12 release? if no, can you change the label, please? |
@macohen: It was merged and backported. I'll write a draft of documentation over at opensearch-project/documentation-website#5151 |
Closing since it was merged and backported already. |
As a user of search pipelines I want a processor that can modify both search requests and responses so I can do things like paginating where the user requests results 21-30, but a reranker needs 1-40 as input; the reranker sorts and then returns 21-30 from the sorted list.
The text was updated successfully, but these errors were encountered: