-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
[ML] performance improvement for precompiled normalization #87709
[ML] performance improvement for precompiled normalization #87709
Conversation
Pinging @elastic/ml-core (Team:ML) |
@@ -144,7 +144,7 @@ Optional<BytesRef> normalizePart(byte[] strBytes, int offset, int len) { | |||
secondIndex++; | |||
} | |||
if (secondIndex == firstIndex) { | |||
return Optional.empty(); | |||
return Optional.of(new BytesRef(BytesRef.EMPTY_BYTES)); |
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.
This was a bug, we should return empty bytes here as when the two indices are equal to eachother, it indicates that this part of the string should be removed (think control characters...)
@elasticmachine update branch |
...n/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizer.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizer.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizer.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.
LGTM
This is a performance improvement for the precompiled normalizer. It no longer requires the graphemes to be sub-strings and relies on code-point counts between grapheme boundaries for normalization.