File size: 884 Bytes
424aef9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from sentence_transformers import SentenceTransformer

MODEL = "Modularcomputing/Native-Bird"

query = "Neuklọs ahụ bụ ahụ ihe abụọ mejupụtara ya - neutrọn na protọn."
documents = [
    "The nucleus consists of two particles - neutrons and protons.",
    "The liver is an organ responsible for many metabolic functions.",
    "Photosynthesis converts light energy into chemical energy.",
]

model = SentenceTransformer(MODEL)
q = model.encode(query, normalize_embeddings=True)
d = model.encode(documents, normalize_embeddings=True)
scores = d @ q

print("Native-Bird cross-lingual retrieval test")
for rank, i in enumerate(scores.argsort()[::-1], 1):
    print(f"{rank}. score={scores[i]:.4f} | {documents[i]}")

assert scores.argmax() == 0, "The expected English match was not ranked first."
print("PASS: Igbo query retrieved the matching English document first.")