-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Add inner hits support to semantic query #111834
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
Conversation
Hi @Mikep86, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technical approach looks reasonable to me, nice work!
...gin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/InnerChunkBuilder.java
Outdated
Show resolved
Hide resolved
...inference/src/yamlRestTest/resources/rest-api-spec/test/inference/40_semantic_text_query.yml
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the approach, I left some minor comments.
...gin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/InnerChunkBuilder.java
Outdated
Show resolved
Hide resolved
.../inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java
Outdated
Show resolved
Hide resolved
.../inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java
Show resolved
Hide resolved
what happens when I query on two semantic_text fields - does it collide under the My first thought is that the retrieved chunks could be positioned more closely to the field source ie Looking at the API interface, I think chunking configuration should step away from being close to configuration of For example: I would see a need to describe retrieval of adjacent chunks on matched chunks. These chunks tend to be small (for precision) but not very helpful to the LLM for context. It would be great if we could specify bring back adjacent chunks to the matched chunk. Example: does |
It does indeed! Good callout, I will fix this.
I don't quite follow here. Do you mean that the nested path
Agreed that this could be useful, but it's quite the scope expansion. I think that would require implementing a new low-level inner hits retrieval mechanism specifically for retrieving chunks. IMO that's best left as a follow up to this, WDYT? I think the |
...inference/src/yamlRestTest/resources/rest-api-spec/test/inference/40_semantic_text_query.yml
Outdated
Show resolved
Hide resolved
To me as a developer, i don't expect the chunk matches to come under Maybe the API request could look like this:
Maybe the API response could look like
My suggestion is we design an interface thats focused on chunking needs vs copying the nested field query design, making sure we are building in a design that sets us up for future features. The examples weren't requirements for this PR but more from surfacing possible chunking requirements. Also worth questioning whether returning the embedding is important here. By default it shouldn't be returned IMO. |
Pinging @elastic/ent-search-eng (Team:SearchOrg) |
My 2 cents is:
Users will always have to read documentation on what the parameter name is. "chunks" vs "parts" vs. "passages" vs. "inner_hits". |
In the spirit of progress over perfection, the first option allows us to merge this change and utilize passage ranking through the Given the LOE to make the second option happen, I just don't see it happening without a discovery phase with a lot of stakeholders and multiple PRs. I would likely spend the majority of 8.16 development time on changes related to the search response format, at the cost of other semantic text features we want to include in 8.16. I also think there's a third option to keep the API as it is now though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 💯
I agree on the approach to use the inner_hits
name in the request, and keep the inner_hits structure.
We're already leaking the inner workings of semantic_text - we're just making them convenient to use in terms of ingestion and query. But we're not hiding the details in case users want to dig deeper.
I understand @joemcelroy statement on making it better from the dev perspective. From my side, I think we benefit more of alignment as of now - we're using inner_hits
config and structure, which is familiar to use and is the inner representation.
We can include the chunks
parameter later on to make something more aligned to the dev experience that builds on top of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! 👏 A couple of very minor comments surrounding error messages and documentation.
} | ||
------------------------------------------------------------ | ||
// TEST[skip:TBD] | ||
// TEST[skip: Requires inference endpoints] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
See <<semantic-query-passage-ranking, Passage ranking with the `semantic` query>> for more information. | ||
+ | ||
.Properties of `inner_hits` | ||
[%collapsible%open] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we usually collapse query DSL properties, based on looking at a few other pages. It's probably not a huge deal but inconsistent with pages like knn
and text_expansion
in the same grouping. Those pages also aren't using the .Properties
syntax. I'll defer to docs experts on which way is "right" 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the look of the collapsible blocks better personally, that's why I went with it :)
@leemthompo Any guidance you can offer here?
.../inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java
Outdated
Show resolved
Hide resolved
.../inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java
Outdated
Show resolved
Hide resolved
💚 Backport successful
|
Adds inner hits support to the semantic query through a restricted inner_hits parameter, which exposes from and size from the inner_hits options
Adds inner hits support to the semantic query through a restricted inner_hits parameter, which exposes from and size from the inner_hits options
Adds inner hits support to the
semantic
query through a restrictedinner_hits
parameter, which exposesfrom
andsize
from the inner_hits options. We chose to do this because the other inner hits options don't make sense in the context of thesemantic
query.The API and response looks like: