Skip to content

Add gemma 3 embedding model#136

Open
CodebyCR wants to merge 10 commits intoml-explore:mainfrom
CodebyCR:add-gemma-3-embedding-model
Open

Add gemma 3 embedding model#136
CodebyCR wants to merge 10 commits intoml-explore:mainfrom
CodebyCR:add-gemma-3-embedding-model

Conversation

@CodebyCR
Copy link
Contributor

@CodebyCR CodebyCR commented Mar 6, 2026

Proposed changes

Please include a description of the problem or feature this PR is addressing. If there is a corresponding issue, include the issue #.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

/// - Returns: An `MLXArray` with the same shape as the original, normalized along `axis`.
///
/// - Complexity: O(n), where n is the total number of elements in the array.
public func l2Normalized(axis: Int = -1, eps: Float = 1e-12) -> MLXArray {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this come from? I wonder if this should be in mlx-swift or even in mlx?

Copy link
Contributor Author

@CodebyCR CodebyCR Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the core idea was to create a proxy Normalizer Scope to generalize and make this more obvious L2Normalisation (and other layers maybe) which should always inlined or inlinable, but it shifts more and more to this extension approach.

I take a look into Swift-MLX there are Linalg.norm() which could solve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidkoski this method depends on the Linalg.norm() method, so moving this to MLX comes with a lot of code movement, but I could make an pull request for Swift- MLX and refactor this occurrence after its merged.


import Foundation
import MLX
@preconcurrency import MLX
Copy link
Collaborator

@davidkoski davidkoski Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? It is either a sign of a bug in mlx-swift or in this test code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happened as I wrote the test. I had imported a deprecated method and the linter judged me, but it is not longer used.

@CodebyCR CodebyCR requested a review from davidkoski March 10, 2026 21:34
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.

2 participants