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

Multi-GPU for more tasks #27

Closed
Muennighoff opened this issue Jul 23, 2022 · 2 comments
Closed

Multi-GPU for more tasks #27

Muennighoff opened this issue Jul 23, 2022 · 2 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@Muennighoff
Copy link
Contributor

It'd be great if we could figure out using multiple gpus on tasks other than BEIR.
E.g. RedditClusteringP2P takes >20h for a 5.8B model with embeddings of 4096 dimensions.

@NouamaneTazi NouamaneTazi added the help wanted Extra attention is needed label Aug 3, 2022
@dylan-hum
Copy link

I wrote a wrapper for the model like this, it seems to be working so far.

class MultiGPUModel(object):
    def __init__(self, sentence_transformer: SentenceTransformer):
        self.transformer = sentence_transformer
        self.gpu_pool = self.transformer.start_multi_process_pool()

    def encode(self, sentences, **kwargs):
        return self.transformer.encode_multi_process(sentences, self.gpu_pool, **kwargs)

Then you can pass it like this:

from mteb import MTEB
from sentence_transformers import SentenceTransformer

# Define the sentence-transformers model name
model_name = "average_word_embeddings_komninos"

model = SentenceTransformer(model_name)
multigpu_model = MultiGPUModel(model)
evaluation = MTEB(tasks=["Banking77Classification"])
results = evaluation.run(multigpu_model , output_folder=f"results/{model_name}")

@Muennighoff
Copy link
Contributor Author

I wrote a wrapper for the model like this, it seems to be working so far.

class MultiGPUModel(object):
    def __init__(self, sentence_transformer: SentenceTransformer):
        self.transformer = sentence_transformer
        self.gpu_pool = self.transformer.start_multi_process_pool()

    def encode(self, sentences, **kwargs):
        return self.transformer.encode_multi_process(sentences, self.gpu_pool, **kwargs)

Then you can pass it like this:

from mteb import MTEB
from sentence_transformers import SentenceTransformer

# Define the sentence-transformers model name
model_name = "average_word_embeddings_komninos"

model = SentenceTransformer(model_name)
multigpu_model = MultiGPUModel(model)
evaluation = MTEB(tasks=["Banking77Classification"])
results = evaluation.run(multigpu_model , output_folder=f"results/{model_name}")

As highlighted in this wrapper, I think this can be done much more easily on the user side and thus does not need to be in MTEB ; Also see #233 :)

KennethEnevoldsen added a commit that referenced this issue Apr 11, 2024
These include 9 datasets (18 points) across 4 news tasks (8) for spanish.

Points are given to violenil as the contributor, and one points for reviewers. Points can be split up if needed.
KennethEnevoldsen added a commit that referenced this issue Apr 11, 2024
* docs: Added missing points for #214

Added 6x2 points for guenthermi for datasets and 1 point to  Muennighoff for review

I have not accounted for bonus points as I am not sure was what available at the time.

* docs: added point for #197

Added 2 points for rasdani and 2 bonus points for the first german retrieval (I believe). Added one point for each of the reviewers

* docs: added points for #116

This includes 6 points for 3 datasets to slvnwhrl +2 for first german clustering task also added points for reviews

* Added points for #134 cmteb

This includes 29 datasets (38 points) and 6x2 bonus points (12 points) for the 6 taskXlanguage which was not previously included.

All the points are attributed to @staoxiao, though we can split them if needed.

We also added points for review.

* docs: Added points for #137 polish

This includes points for 12 datasets (24) across 4 tasks (8). These points are given to rafalposwiata and then one point for review

* docs: Added points for #27 (spanish)

These include 9 datasets (18 points) across 4 news tasks (8) for spanish.

Points are given to violenil as the contributor, and one points for reviewers. Points can be split up if needed.

* docs: Added points for #224

Added points 2 points for the dataset. I could imagine that I might have missed some bonus points as well. Also added one point for review.

* docs: Added points for #210 (korean)

This include 3 datasets (6 points) across 1 new task (+2 bonus) for korean. Also added 1 points for reviewers.

* Add contributor

---------

Co-authored-by: Niklas Muennighoff <n.muennighoff@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants