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

support musa backend in FlagEmbedding #1350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qiyulei-mt
Copy link

What does this PR do?
It supports utilization of Moore Threads GPU in FlagEmbedding. The input of devices can be 0, [0], ["musa:0"], "musa:0". For example, the case below, you can set devices as 0, [0], ["musa:0"], "musa:0".

import os
from FlagEmbedding import FlagModel

model = FlagModel(
    'BAAI/bge-small-en-v1.5',
    query_instruction_for_retrieval="Represent this sentence for searching relevant passages: ",
    query_instruction_format="{}{}",
    devices="musa:3",
    pooling_method='cls',
    cache_dir=os.getenv('HF_HUB_CACHE', None),
)

queries = [
    "What is the capital of France?",
    "What is the population of China?",
] * 100
passages = [
    "Paris is the capital of France.",
    "The population of China is over 1.4 billion people."
] * 100

queries_embeddings = model.encode_queries(queries)
passages_embeddings = model.encode_corpus(passages)

cos_scores = queries_embeddings @ passages_embeddings.T
print(cos_scores[:2, :2])

After running the code, you can get corresponding results.

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.

1 participant