Omartificial-Intelligence-Space
commited on
Commit
•
497f5cd
1
Parent(s):
76e6288
Update readme.md
Browse files
README.md
CHANGED
@@ -1,3 +1,114 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- ar
|
5 |
+
pipeline_tag: text-classification
|
6 |
+
tags:
|
7 |
+
- transformers
|
8 |
+
- sentence-transformers
|
9 |
+
- text-embeddings-inference
|
10 |
+
---
|
11 |
+
|
12 |
+
# Introducing ARM-V1 | Arabic Reranker Model (Version 1)
|
13 |
+
|
14 |
+
**For more info please refer to this blog: [ARM | Arabic Reranker Model](www.omarai.me).**
|
15 |
+
|
16 |
+
✨ This model is designed specifically for Arabic language reranking tasks, optimized to handle queries and passages with precision.
|
17 |
+
|
18 |
+
✨ Unlike embedding models, which generate vector representations, this reranker directly evaluates the similarity between a question and a document, outputting a relevance score.
|
19 |
+
|
20 |
+
✨ Trained on a combination of positive and hard negative query-passage pairs, it excels in identifying the most relevant results.
|
21 |
+
|
22 |
+
✨ The output score can be transformed into a [0, 1] range using a sigmoid function, providing a clear and interpretable measure of relevance.
|
23 |
+
|
24 |
+
## Arabic RAG Pipeline
|
25 |
+
|
26 |
+
|
27 |
+
![Arabic RAG Pipeline](https://i.ibb.co/z4Fc3Kd/Screenshot-2024-11-28-at-10-17-39-AM.png)
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
## Usage
|
32 |
+
### Using sentence-transformers
|
33 |
+
|
34 |
+
```
|
35 |
+
pip install sentence-transformers
|
36 |
+
```
|
37 |
+
```python
|
38 |
+
from sentence_transformers import CrossEncoder
|
39 |
+
|
40 |
+
# Load the cross-encoder model
|
41 |
+
|
42 |
+
# Define a query and a set of candidates with varying degrees of relevance
|
43 |
+
query = "تطبيقات الذكاء الاصطناعي تُستخدم في مختلف المجالات لتحسين الكفاءة."
|
44 |
+
|
45 |
+
# Candidates with varying relevance to the query
|
46 |
+
candidates = [
|
47 |
+
"الذكاء الاصطناعي يساهم في تحسين الإنتاجية في الصناعات المختلفة.", # Highly relevant
|
48 |
+
"نماذج التعلم الآلي يمكنها التعرف على الأنماط في مجموعات البيانات الكبيرة.", # Moderately relevant
|
49 |
+
"الذكاء الاصطناعي يساعد الأطباء في تحليل الصور الطبية بشكل أفضل.", # Somewhat relevant
|
50 |
+
"تستخدم الحيوانات التمويه كوسيلة للهروب من الحيوانات المفترسة.", # Irrelevant
|
51 |
+
]
|
52 |
+
|
53 |
+
# Create pairs of (query, candidate) for each candidate
|
54 |
+
query_candidate_pairs = [(query, candidate) for candidate in candidates]
|
55 |
+
|
56 |
+
# Get relevance scores from the model
|
57 |
+
scores = model.predict(query_candidate_pairs)
|
58 |
+
|
59 |
+
# Combine candidates with their scores and sort them by score in descending order (higher score = higher relevance)
|
60 |
+
ranked_candidates = sorted(zip(candidates, scores), key=lambda x: x[1], reverse=True)
|
61 |
+
|
62 |
+
# Output the ranked candidates with their scores
|
63 |
+
print("Ranked candidates based on relevance to the query:")
|
64 |
+
for i, (candidate, score) in enumerate(ranked_candidates, 1):
|
65 |
+
print(f"Rank {i}:")
|
66 |
+
print(f"Candidate: {candidate}")
|
67 |
+
print(f"Score: {score}\n")
|
68 |
+
```
|
69 |
+
## Evaluation
|
70 |
+
### Dataset
|
71 |
+
|
72 |
+
Size: 3000 samples.
|
73 |
+
|
74 |
+
### Structure:
|
75 |
+
🔸 Query: A string representing the user's question.
|
76 |
+
|
77 |
+
🔸 Candidate Document: A candidate passage to answer the query.
|
78 |
+
|
79 |
+
🔸 Relevance Label: Binary label (1 for relevant, 0 for irrelevant).
|
80 |
+
|
81 |
+
### Evaluation Process
|
82 |
+
|
83 |
+
🔸 Query Grouping: Queries are grouped to evaluate the model's ability to rank candidate documents correctly for each query.
|
84 |
+
|
85 |
+
🔸 Model Prediction: Each model predicts relevance scores for all candidate documents corresponding to a query.
|
86 |
+
|
87 |
+
🔸 Metrics Calculation: Metrics are computed to measure how well the model ranks relevant documents higher than irrelevant ones.
|
88 |
+
|
89 |
+
| Model | MRR | MAP | nDCG@10 |
|
90 |
+
|-------------------------------------------|------------------|------------------|------------------|
|
91 |
+
| cross-encoder/ms-marco-MiniLM-L-6-v2 | 0.631 | 0.6313| 0.725 |
|
92 |
+
| cross-encoder/ms-marco-MiniLM-L-12-v2 | 0.664 | 0.664 | 0.750 |
|
93 |
+
| BAAI/bge-reranker-v2-m3 | 0.902 | 0.902 | 0.927 |
|
94 |
+
| Omartificial-Intelligence-Space/ARA-Reranker-V1 | **0.934** | **0.9335** | **0.951** |
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
## <span style="color:blue">Acknowledgments</span>
|
99 |
+
|
100 |
+
The author would like to thank Prince Sultan University for their invaluable support in this project. Their contributions and resources have been instrumental in the development and fine-tuning of these models.
|
101 |
+
|
102 |
+
|
103 |
+
```markdown
|
104 |
+
## Citation
|
105 |
+
|
106 |
+
If you use the GATE, please cite it as follows:
|
107 |
+
|
108 |
+
@misc{nacar2025ARM,
|
109 |
+
title={ARM, Arabic Reranker Model},
|
110 |
+
author={Omer Nacar},
|
111 |
+
year={2025},
|
112 |
+
url={https://huggingface.co/Omartificial-Intelligence-Space/ARA-Reranker-V1},
|
113 |
+
}
|
114 |
+
|