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

Question, how to use embedding using mps ? #19

Open
x4080 opened this issue May 20, 2024 · 2 comments
Open

Question, how to use embedding using mps ? #19

x4080 opened this issue May 20, 2024 · 2 comments

Comments

@x4080
Copy link

x4080 commented May 20, 2024

Here's the embedding code :

from optimum.onnxruntime import ORTModelForFeatureExtraction
from transformers import AutoModel, AutoTokenizer
import numpy as np

model_ort = ORTModelForFeatureExtraction.from_pretrained('BAAI/bge-small-en-v1.5', file_name="onnx/model.onnx")
tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-small-en-v1.5')
model = AutoModel.from_pretrained('BAAI/bge-small-en-v1.5')
...
inputs = tokenizer(documents, padding=True, truncation=True, return_tensors='pt', max_length=512)
embeddings = model(**inputs)[0][:, 0].detach().numpy()

It works but only using cpu, when I tried using to("mps"), it wont work

How can I use mps for this scenario ?

Thanks

@henryruhs
Copy link

Use the official onnxruntime, this repo is outdated and can be archived.

@x4080
Copy link
Author

x4080 commented Jun 27, 2024

@henryruhs I see, thanks

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

No branches or pull requests

2 participants