Skip to content

feat: add bidirectional Ministral3 embeddings - #75

Open
StartupBros wants to merge 3 commits into
Blaizzy:mainfrom
StartupBros:ministral3-bidirectional-embeddings
Open

feat: add bidirectional Ministral3 embeddings#75
StartupBros wants to merge 3 commits into
Blaizzy:mainfrom
StartupBros:ministral3-bidirectional-embeddings

Conversation

@StartupBros

@StartupBros StartupBros commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Add a bidirectional Ministral3 encoder adapter for SentenceTransformers embedding checkpoints such as nvidia/Nemotron-3-Embed-1B-BF16.

Implementation

  • Reuse mlx-lm’s Ministral3 layers and YaRN implementation.
  • Replace causal masking with a full bidirectional additive mask that excludes padding keys.
  • Return sequence hidden states plus normalized masked-mean embeddings.
  • Preserve checkpoint-native tensor names through explicit model.* sanitation.
  • Fail closed for causal architectures or non-full-attention layer layouts.

Verification

  • Full mlx-embeddings suite: 56 passed.
  • Ruff, Black, and git diff --check: pass.
  • Real pinned 1B BF16 checkpoint loads and compiles through the oMLX embedding wrapper.
  • Four 2048-dimensional MLX vectors compared with normalized sentence-transformers Torch CPU outputs:
    • minimum per-vector cosine: 0.999756
    • all dimensions: 2048
    • module-declared mean pooling exercised

No model repository code is executed, and no checkpoint files are rewritten.

@StartupBros
StartupBros marked this pull request as ready for review September 3, 2026 00:04
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