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

Setting up SentenceTransformerEmbeddingModel for GPU use. #641

Open
Snikch63200 opened this issue Oct 25, 2024 · 3 comments
Open

Setting up SentenceTransformerEmbeddingModel for GPU use. #641

Snikch63200 opened this issue Oct 25, 2024 · 3 comments
Labels
question Further information is requested

Comments

@Snikch63200
Copy link

Hello,

I finally managed to use a local embedding model (mxbai-embed-large-v1) using new SentenceTransformerEmbeddingModel class (thenks to developper team for this work !!! ;-)).

sparse_embedding_model = SparseEmbeddingModel(ndim=4096)
sentence_transformer = SentenceTransformerEmbeddingModel(name="mixedbread-ai/mxbai-embed-large-v1",
                                                         )
hybrid_model=HybridEmbeddingModel(models=[sparse_embedding_model,sentence_transformer])

It works fine but it's very slow because doesn't use GPU...
Is it a way to force model to use GPU (in config options I guess...).

Thanks for help.

@dosu.

Copy link

dosubot bot commented Oct 25, 2024

To configure the SentenceTransformerEmbeddingModel to use the GPU for the mxbai-embed-large-v1 model, you need to set the device parameter in the config dictionary to "cuda". Here's how you can modify your code:

sparse_embedding_model = SparseEmbeddingModel(ndim=4096)
sentence_transformer = SentenceTransformerEmbeddingModel(
    name="mixedbread-ai/mxbai-embed-large-v1",
    config={"device": "cuda"}  # Set the device to GPU
)
hybrid_model = HybridEmbeddingModel(models=[sparse_embedding_model, sentence_transformer])

This configuration will ensure that the model uses the GPU for computations [1].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the question Further information is requested label Oct 25, 2024
@Snikch63200
Copy link
Author

Works fine !! Thanks.

GPU is MUCH faster for this task !

Where could I find a complet lis of available options for 'config' dict (config={"device": "cuda"})

@dosu.

Copy link

dosubot bot commented Oct 25, 2024

The available configuration options for the SentenceTransformerEmbeddingModel in the codebase are:

  • batch_size: Specifies the batch size for processing the texts. The default value is 32.
  • device: Specifies the device on which the model should run, such as "cpu" or "cuda". The default value is "cpu" [1][2].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant