Native-Bird / test_native_bird.py
UncleanCode's picture
Upload via Autoresearch export_data
424aef9 verified
Raw History Blame Contribute Delete
884 Bytes
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.")