Instructions to use BAAI/bge-multilingual-gemma2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use BAAI/bge-multilingual-gemma2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("BAAI/bge-multilingual-gemma2") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use BAAI/bge-multilingual-gemma2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="BAAI/bge-multilingual-gemma2")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("BAAI/bge-multilingual-gemma2") model = AutoModel.from_pretrained("BAAI/bge-multilingual-gemma2") - Inference
- Notebooks
- Google Colab
- Kaggle
FlagEmbedding example returns [[nan nan] [nan nan]]
I follow the example, but either embeddings_1 nor embeddings_2 returns all nans in the array, thanks for helping
Hello, @hcnhcn012 ! Could you provide more details? For example, the machine (CPU/GPU) or the float precision (fp32/fp16/bf16) you used. Then I will check the possible cause of the problem.
@hcnhcn012
I had this issue when using SentenceTransformers. I found that setting model_kwargs={"torch_dtype": torch.float16} as shown in the examples seems to prevent this issue.
@hcnhcn012
I had this issue when using SentenceTransformers. I found that setting model_kwargs={"torch_dtype": torch.float16} as shown in the examples seems to prevent this issue.
@hliusonmsft Yes it works, thanks
Hello, @hcnhcn012 ! Could you provide more details? For example, the machine (CPU/GPU) or the float precision (fp32/fp16/bf16) you used. Then I will check the possible cause of the problem.
@hanhainebula my gpu is Nvidia-L20, and using default float precision when calling FlagEmbedding, but it worked well when i turned to SentenceTransformers API