Views
No views yet

pip install sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Load the cross-encoder model
4
5# Define a query and a set of candidates with varying degrees of relevance
6query = "تطبيقات الذكاء الاصطناعي تُستخدم في مختلف المجالات لتحسين الكفاءة."
7
8# Candidates with varying relevance to the query
9candidates = [
10 "الذكاء الاصطناعي يساهم في تحسين الإنتاجية في الصناعات المختلفة.", # Highly relevant
11 "نماذج التعلم الآلي يمكنها التعرف على الأنماط في مجموعات البيانات الكبيرة.", # Moderately relevant
12 "الذكاء الاصطناعي يساعد الأطباء في تحليل الصور الطبية بشكل أفضل.", # Somewhat relevant
13 "تستخدم الحيوانات التمويه كوسيلة للهروب من الحيوانات المفترسة.", # Irrelevant
14]
15
16# Create pairs of (query, candidate) for each candidate
17query_candidate_pairs = [(query, candidate) for candidate in candidates]
18
19# Get relevance scores from the model
20scores = model.predict(query_candidate_pairs)
21
22# Combine candidates with their scores and sort them by score in descending order (higher score = higher relevance)
23ranked_candidates = sorted(zip(candidates, scores), key=lambda x: x[1], reverse=True)
24
25# Output the ranked candidates with their scores
26print("Ranked candidates based on relevance to the query:")
27for i, (candidate, score) in enumerate(ranked_candidates, 1):
28 print(f"Rank {i}:")
29 print(f"Candidate: {candidate}")
30 print(f"Score: {score}\n")| Model | MRR | MAP | nDCG@10 |
|---|---|---|---|
| cross-encoder/ms-marco-MiniLM-L-6-v2 | 0.631 | 0.6313 | 0.725 |
| cross-encoder/ms-marco-MiniLM-L-12-v2 | 0.664 | 0.664 | 0.750 |
| BAAI/bge-reranker-v2-m3 | 0.902 | 0.902 | 0.927 |
| Omartificial-Intelligence-Space/ARA-Reranker-V1 | 0.934 | 0.9335 | 0.951 |
1## Citation
2
3If you use the GATE, please cite it as follows:
4
5@misc{nacar2025ARM,
6 title={ARM, Arabic Reranker Model},
7 author={Omer Nacar},
8 year={2025},
9 url={https://huggingface.co/Omartificial-Intelligence-Space/ARA-Reranker-V1},
10}
11
12
13
14