Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: MLX embedding #2275

Open
Rehan-shah opened this issue Jun 3, 2024 · 2 comments
Open

[Feature Request]: MLX embedding #2275

Rehan-shah opened this issue Jun 3, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Rehan-shah
Copy link

Describe the problem

I prefer if ChromaDB had integration with mlx for creating embedding on Mac as it is more efficient than PyTorch for Apple silicon chips.

Describe the proposed solution

Using mix examples repo's Bert folder to create embeddings

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@Rehan-shah Rehan-shah added the enhancement New feature or request label Jun 3, 2024
@tazarov
Copy link
Contributor

tazarov commented Jun 3, 2024

@Rehan-shah, thanks for raising this. I think it is related to #1751

@tazarov
Copy link
Contributor

tazarov commented Jun 3, 2024

@Rehan-shah, this looks good - https://github.com/ml-explore/mlx-examples/tree/main/bert

seems straight-forward to make it work with our default embedding model all-MiniLM-L6-v2:

python convert.py \ 
    --bert-model sentence-transformers/all-MiniLM-L6-v2 \
    --mlx-model weights/all-MiniLM-L6-v2.npz
import mlx.core as mx
from model import Bert, load_model

model, tokenizer = load_model(
    "sentence-transformers/all-MiniLM-L6-v2",
    "weights/all-MiniLM-L6-v2.npz")

batch = ["This is an example of BERT working on MLX."]
tokens = tokenizer(batch, return_tensors="np", padding=True)
tokens = {key: mx.array(v) for key, v in tokens.items()}

output, pooled = model(**tokens)

The MLX works with other BERT models, which can be a new EF's starting point.

Rehan-shah added a commit to Rehan-shah/chroma that referenced this issue Jun 5, 2024
Rehan-shah added a commit to Rehan-shah/chroma that referenced this issue Jun 5, 2024
[FEAT] Add mlx embedding

[FEAT] Add mlx embedding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants