Views
No views yet
| Model Name | Dimension | Sequence Length | Introduction |
|---|---|---|---|
| abdulmatinomotoso/bge-m3-finetuned | 1024 | 8192 | multilingual; contrastive learning from bge-m3 |
| Dataset | Description |
|---|---|
| bge-m3-finetuned-data | Fine-tuning data used by bge-m3-finetuned |
1
2import torch
3from FlagEmbedding import BGEM3FlagModel
4
5device = "cpu"
6if torch.cuda.is_available():
7 device = "cuda"
8elif torch.backends.mps.is_available():
9 device = "mps"
10
11half_precision = False # or True if you really want
12# Load the abdulmatinomotoso/bge-finetuned model
13model = BGEM3FlagModel('abdulmatinomotoso/bge-finetuned', use_fp16=half_precision, devices=[device])
14
15# Example text to generate embeddings for
16documents = [
17 "Eyi jẹ́ gbolohun àpẹẹrẹ",
18 "Eyi kì í ṣe gbolohun àpẹẹrẹ",
19
20 "Nke a bụ nkebisiokwu atụ",
21 "Nke a abụghị nkebisiokwu atụ",
22
23 "Wannan jimla ce ta misali",
24 "Wannan ba jimla ce ta misali ba"
25]
26
27query = "Where is the example?"
28
29# Generate embeddings
30sparse_embeddings = False # The sparse embeddings are not useful as is, they will require some work to make the align with the entire model.
31multivec_embeddings = False # The multivector embeddings are still useful despite training only for dense, but this sample uses only dense embeddings
32dense_embeddings = True
33
34doc_embeddings = model.encode(documents, return_sparse=sparse_embeddings, return_dense=dense_embeddings, return_colbert_vecs=multivec_embeddings)["dense_vecs"]
35
36query_embeddings = model.encode([query], return_sparse=sparse_embeddings, return_dense=dense_embeddings, return_colbert_vecs=multivec_embeddings)["dense_vecs"]
37
38similarity_scores = query_embeddings @ doc_embeddings.T
39print(similarity_scores)
40# array([[
41# 0.4360781, # Higher similarity than the opposite text
42# 0.40966046,
43
44# 0.4775736, # Higher similarity than the opposite text
45# 0.44197953,
46
47# 0.4514127, # Higher similarity than the opposite text
48# 0.41557986
49# ]], dtype=float32)
50@inproceedings{omotoso-etal-2025-improving,
title = {Improving BGE-M3 Multilingual Dense Embeddings for Nigerian Low Resource Languages},
author = {Omotoso, Abdulmatin and Shopeju, Habeeb and Joshua, Adejumobi Monjolaoluwa and Oni, Shiloh},
booktitle = {Proceedings of the 9th Widening NLP Workshop},
year = {2025},
month = nov,
address = {Suzhou, China},
publisher = {Association for Computational Linguistics},
pages = {224--229},
doi = {10.18653/v1/2025.winlp-main.33},
url = {https://aclanthology.org/2025.winlp-main.33/}
}