-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Default new semantic_text fields to use BBQ when models are compatible #126629
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
Default new semantic_text fields to use BBQ when models are compatible #126629
Conversation
Pinging @elastic/search-eng (Team:SearchOrg) |
Pinging @elastic/search-relevance (Team:Search - Relevance) |
Hi @kderusso, I've created a changelog YAML for you. |
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
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 appreciate that we're keeping index options as an implementation detail of the semantic text field. That said, with this change, existing semantic text fields will start using BBQ immediately. I'm in favor of this behavior (rather than reserving this change for only new indices), but I wanted to explicitly call it out for awareness before we proceed with the merge since that's not exactly what we discussed.
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 think updating existing semantic text fields to use BBQ could cause major problems. For example, take a look at the Int8 HNSW update logic. It only allows updates to Int4 HNSW. The end effect of this change is that every semantic text field using Int8 HNSW could start failing on document ingest.
Yep, that was too good to be true, @Mikep86. |
Good catch @Mikep86 - Added a gate on |
...nference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
Outdated
Show resolved
Hide resolved
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
Outdated
Show resolved
Hide resolved
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
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.
Nice index version solution in SemanticTextFieldMapperTests
, I believe that covers our needs and we can revert changes to getRandomCompatibleIndexVersion
.
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 solution here that both constrains the index versions and maintains randomness 🙌 !
@@ -114,18 +117,18 @@ public MappedFieldType getMappedFieldType() { | |||
} | |||
|
|||
static IndexVersion getRandomCompatibleIndexVersion(boolean useLegacyFormat) { | |||
return getRandomCompatibleIndexVersion(useLegacyFormat, IndexVersion.current()); |
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.
Based on your changes in SemanticTextFieldMapperTests
, I don't think we need any changes to getRandomCompatibleIndexVersion
? These changes create some usability challenges:
maxVersion
is only selectively used, which could be confusing to future devs.- What if
maxVersion
is less thanIndexVersions.UPGRADE_TO_LUCENE_10_0_0
orIndexVersions.INFERENCE_METADATA_FIELDS
? This will result in an error, and one that is thrown based on a randomization factor as well, which will be very confusing.
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.
We need this because otherwise one of the cases in SemanticInferenceMetadataFieldMapperTests#isEnabled
will fail as it depends on the old, less inclusive legacy format logic. You can see the modifications to the test for this here: 6cfe39a
I could have removed the test, but that didn't feel right. I think this is OK, if we need to extend it later for additional tests we can do so as needed.
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.
What I'm confused about is why reverting changes to both getRandomCompatibleIndexVersion
and testIsEnabled
isn't an option. This should work fine as this is the state of the test before this PR, no?
And that approach should work with your changes in SemanticTextFieldMapperTests
, so I see it as the best path for the moment.
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.
We already have some followup work on this test, why don't we roll that into the scope?
IndexVersions.INFERENCE_METADATA_FIELDS, | ||
IndexVersionUtils.getPreviousVersion(IndexVersions.SEMANTIC_TEXT_DEFAULTS_TO_BBQ) | ||
); | ||
assertSemanticTextField(mapperService, "field", true, null, SemanticTextFieldMapper.defaultSemanticDenseIndexOptions()); |
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 believe this should be defaultDenseVectorIndexOptions
?
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.
Good catch. Updated the test, though it's failing right now. It's picking up the correct index options, but in the debugger it's not getting passed in to the mapper. Troubleshooting this now.
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.
So in SemanticTextFieldMapperTests#createMapperService, we set the index version created as a setting, and then create the mapping with those specified settings here.
In the MapperServiceTestCase, this calls getVersion(), which always returns IndexVersion.current().
I fixed this, so we ensure that we can pass in the actual version we want to create. This makes this test do the right thing and pass, but there’s a side effect in that a few different existing tests fail due to things like created on a 7.17 index, not having an indexed field, etc. To be clear I believe this is a test error and not an error with semantic_text
code.
For this PR, just to get it in and over the line, I hacked in a fix that will not propagate the correct index version, so the tests work the same as they always have. We should make some time to address it. Commit here: 4a7fad9
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.
Looks good, thanks for the (many) iterations here!
💔 Backport failed
You can use sqren/backport to manually backport by running |
elastic#126629) * Default new semantic_text fields to use BBQ when models are compatible * Update docs/changelog/126629.yaml * Gate default BBQ by IndexVersion * Cleanup from PR feedback * PR feedback * Fix test * Fix test * PR feedback * Update test to test correct options * Hack alert: Fix issue where mapper service was always being created with current index version (cherry picked from commit a72883e) # Conflicts: # server/src/main/java/org/elasticsearch/index/IndexVersions.java # server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
Note: #124581 was not backported, so I have not backported this to 8.x. This means that unless the previous PR is backported, this change will only be in 9.1+. We can revisit this decision later on, but for now I've made the appropriate label changes on this PR. |
…ompatible (elastic#126629)" This reverts commit a72883e.
While
dense_vector
fields default toint8_hnsw
for now, we have demonstrated significantly better performance in text embedding models withbbq_hnsw
. As this is the primary use case forsemantic_text
, we are making this the default quantization method forsemantic_text
fields using text embedding models. Models that are incompatible with BBQ due to dimention count or element type will continue to use thedense_vector
quantization defaults.