File size: 3,733 Bytes
da86678
5ff260f
 
51a1c2e
5ff260f
 
51a1c2e
 
 
 
 
5ff260f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da86678
 
 
 
5ff260f
 
 
da86678
 
 
 
5ff260f
da86678
5ff260f
 
 
 
 
 
 
 
 
da86678
 
 
5ff260f
da86678
5ff260f
 
 
da86678
5ff260f
da86678
5ff260f
da86678
5ff260f
da86678
5ff260f
 
 
da86678
5ff260f
da86678
5ff260f
 
da86678
5ff260f
 
 
 
 
 
 
 
 
e89de90
5ff260f
da86678
5ff260f
da86678
5ff260f
 
 
e89de90
5ff260f
da86678
5ff260f
da86678
5ff260f
da86678
5ff260f
 
 
 
 
 
da86678
5ff260f
da86678
5ff260f
 
 
 
 
 
 
da86678
5ff260f
da86678
5ff260f
da86678
5ff260f
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
tags:
  - sentence-transformers
  - text-retrieval
  - sentence-similarity
  - feature-extraction
  - semantic-search
  - amharic
  - text-embedding-inference
  - transformers

pipeline_tag: sentence-similarity
library_name: sentence-transformers
license: mit
metrics:
  - cosine_accuracy
model-index:
  - name: SentenceTransformer
    results:
      - task:
          type: triplet
          name: Triplet
        dataset:
          name: TestTripletEvaluator
          type: TestTripletEvaluator
        metrics:
          - type: cosine_accuracy
            value: 0.875
            name: Cosine Accuracy
---

# SentenceTransformer Fine-Tuned for Amharic Retrieval

This model is a [sentence-transformers](https://www.sbert.net) model finetuned on Amharic QA triplets. It maps sentences and paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

## Model Details

- **Model Type:** Sentence Transformer
- **Base Model:** `sentence-transformers/paraphrase-xlm-r-multilingual-v1`
- **Training Task:** Triplet loss with Matryoshka loss
- **Language:** Amharic
- **Maximum Sequence Length:** 128 tokens
- **Output Dimensionality:** 768 dimensions
- **Similarity Function:** Cosine Similarity

## Training Overview

- **Training Data:** Custom Amharic QA triplets (with positive and negative examples)
- **Training Strategy:**  
  The model was finetuned using a combination of triplet loss and a Matryoshka loss, with evaluation performed using a `TripletEvaluator`.
- **Hyperparameters:**  
  - Epochs: 3  
  - Batch Size: 16  
  - Learning Rate: 1e-6  
  - Warmup Ratio: 0.08  
  - Weight Decay: 0.05

## Evaluation

The model was evaluated on a held-out test set using cosine similarity as the metric:

| Metric              | Value  |
|---------------------|--------|
| **Cosine Accuracy** | 0.875  |

## Usage

To use the model in your own project:

1. **Install Sentence Transformers:**

   ```bash
   pip install -U sentence-transformers
   ```

2. **Load the Model:**

   ```python
   from sentence_transformers import SentenceTransformer

   model = SentenceTransformer("abdulmunimjemal/xlm-r-retrieval-am-v5")
   sentences = [
       "αˆ°αˆ›α‹­ αˆαŠ• αŠ α‹­αŠα‰΅ α‰€αˆˆαˆ αŠα‹?",
       "αˆ°αˆ›α‹­ αˆ°αˆ›α‹«α‹Š α‰€αˆˆαˆ αŠ αˆˆα‹α’" ,
       "αŠ₯αŠ” ምሳ αŠ₯αŠ•αŒ€αˆ« α‰ αˆ‹αˆα’" ,
       "α‰£αˆ•αˆ­ αˆαŠ• αŠ α‹­αŠα‰΅ α‰€αˆˆαˆ αŠα‹?",
       "αŠ α‹¨αˆ­ α‰ αˆα‹΅αˆ­ α‹™αˆͺα‹« α‹«αˆˆ αŠα‹α’"
   ]
   embeddings = model.encode(sentences)
   print(embeddings.shape)  # Expected output: (5, 768)
   ```

3. **Compute Similarity:**

   ```python
   from sklearn.metrics.pairwise import cosine_similarity
   similarities = cosine_similarity(embeddings, embeddings)
   print(similarities.shape)  # Expected output: (5, 5)
   ```

## Model Architecture

Below is an outline of the model architecture:

```
SentenceTransformer(
  (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: XLMRobertaModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_mean_tokens': True, ...})
)
```

## Training Environment

- **Python:** 3.11.11
- **Sentence Transformers:** 3.3.1
- **Transformers:** 4.47.1
- **PyTorch:** 2.5.1+cu124
- **Accelerate:** 1.2.1
- **Datasets:** 3.2.0
- **Tokenizers:** 0.21.0

## Citation

If you use this model in your research, please cite it appropriately.

```bibtex
@misc{your_model,
  title = {SentenceTransformer Fine-Tuned for Amharic Retrieval},
  author = {Abdulmunim J. Jemal},
  year = {2025},
  howpublished = {Hugging Face Model Hub, \url{https://huggingface.co/abdulmunimjemal/xlm-r-retrieval-am-v1}}
}
```