Repository navigation
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.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: qdrant/fastembed
Length of output: 30237
Validate the batch dimension for
DISABLEDpooling.A registered custom ONNX model can return per-token output with the batch axis squeezed to
(sequence_length, embedding_dim). The new check accepts this because it checks onlyndim == 2. The post-processing path iterates the returned array, so each token row can be yielded as a separate document embedding.Compare the output batch dimension with the input batch size before returning
DISABLEDoutput.Suggested fix
def _post_process_onnx_output( self, output: OnnxOutputContext, **kwargs: Any ) -> Iterable[NumpyArray]: embeddings = self._normalize(self._pool(output.model_output, output.attention_mask)) + if ( + self._pooling == PoolingType.DISABLED + and output.input_ids is not None + and embeddings.shape[0] != output.input_ids.shape[0] + ): + raise ValueError( + f"{PoolingType.DISABLED} pooling returned {embeddings.shape[0]} embeddings " + f"for a batch of {output.input_ids.shape[0]} documents" + ) # mean pooling returns float64, float embeddings are cast back to the dtype of the model🤖 Prompt for AI Agents