Skip to content

fix: keep the model dtype in mean pooling embeddings - #754

Merged
joein merged 2 commits into
mainfrom
fix-mean-pooling-dtype
Oct 2, 2026
Merged

joein merged 2 commits into
mainfrom
fix-mean-pooling-dtype

Conversation

@joein

@joein joein commented Sep 30, 2026

Copy link
Copy Markdown
Member

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 7ee7eb4f-25f4-4285-b63a-0d6da99ff373

📥 Commits

Reviewing files that changed from the base of the PR and between 8f1bd82 and c1cdadb.

📒 Files selected for processing (3)
  • tests/test_common.py
  • tests/test_custom_models.py
  • tests/test_text_onnx_embeddings.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Normalization now handles float16 input through float32 calculations and returns float16 results. Mean pooling excludes padded tokens and accumulates in float64. ONNX embedding post-processing casts pooled outputs to model output dtypes under the specified conditions. Tests check pooling, normalization, and embedding output dtypes. The README example now displays float16 document and query embeddings.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c1cda

The change keeps embedding output dtypes consistent with the model and improves float16 precision handling. No merge-blocking issue was found in the supplied context.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to c1cda

The reviewed changes preserve embedding precision without adding privileged operations or broadening access. No material security risk was identified in the changed behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated change propagates to consumers of embedding arrays through numerical values and dtype. The reviewed source does not demonstrate an expansion of tenant, service, credential, or data-store access; downstream application-specific security decisions remain outside the available evidence.

Trust Boundaries and Controls

  • observed — The inspected processing retains missing-attention-mask checks for mean pooling and pooled document processing. Dtype conversion operates on model output without granting new authority or changing caller identity.

Resilience and Maintainability Implications

  • observed — The changed methods calculate and return arrays without mutating shared registries or persistent state. No new multi-step ownership, cleanup, recovery, or rollback transition appears in these methods.
🚥 Pre-merge checks | ✅ 3 | ❌ 1 | ❓ 1

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description contains only the issue reference "#752" and does not explain the changeset. Add a concise description of the dtype-preservation changes in mean pooling and related embedding post-processing.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: preserving the model dtype during mean pooling embeddings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@joein
joein merged commit 2f2a8bf into main Oct 2, 2026
17 checks passed
@joein
joein deleted the fix-mean-pooling-dtype branch October 2, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant