Repository navigation
Conversation
embed_batch() pads short texts to equal length and runs them through a single forward pass. Long texts (>2048 tokens) take a windowed stride path. embed() is now a thin wrapper. Shared filter_and_normalize() eliminates the duplicated MIN_NORM + L2 normalization logic. In embed_chunks, replace the single-doc Gatherer iterator with a loop that collects rows into batches of 32 before embedding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jacobgorm
reviewed
Apr 22, 2026
| let (scores, position_bias) = match position_bias { | ||
| Some(position_bias) => { | ||
| let scores = crate::fast_ops::fast_add(&scores, position_bias)?; | ||
| let scores = scores.broadcast_add(position_bias)?; |
Collaborator
There was a problem hiding this comment.
I am fairly sure our fast_add was indeed a lot faster than broadcast_add in candle
Collaborator
|
I tried testing this change with: make nfcorpusBut it hangs for me |
Collaborator
|
I've pushed fully self-contained nfcorpus scoring support to master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Embedding short documents one at a time wastes GPU/CPU cycles on per-call overhead. The T5 encoder can process multiple sequences in a single forward pass if they're padded to equal length.
Changes