Sentence Similarity
Transformers
Safetensors
Ganda
sagepond_un_model
feature-extraction
luganda
embeddings
sentence-embeddings
semantic-search
research
custom_code
Eval Results (legacy)
Instructions to use sagepond/embedding-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sagepond/embedding-small with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("sagepond/embedding-small", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,137 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- lug
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: sentence-similarity
|
| 7 |
+
tags:
|
| 8 |
+
- luganda
|
| 9 |
+
- embeddings
|
| 10 |
+
- sentence-embeddings
|
| 11 |
+
- semantic-search
|
| 12 |
+
- research
|
| 13 |
---
|
| 14 |
+
|
| 15 |
+
# SAGE POND Luganda Sentence Embedding Model
|
| 16 |
+
|
| 17 |
+
This is a sentence-embedding model developed by SAGE POND for experimentation with semantic representations in Luganda. It maps an input sentence to a **3,072-dimensional, L2-normalized embedding** that can be compared with other sentence embeddings using cosine similarity or used as a representation in downstream semantic applications.
|
| 18 |
+
|
| 19 |
+
## Intended use
|
| 20 |
+
|
| 21 |
+
The model was trained on **sentences**, not question-and-answer pairs, instruction-response examples, or conversational QA data. It should therefore be treated as a sentence-level embedding model rather than a question-answering model or a general-purpose conversational model.
|
| 22 |
+
|
| 23 |
+
The release is intended as a research example and an accessible starting point for people experimenting with Luganda language representations. It can also be used to build prototypes and semantic applications, including:
|
| 24 |
+
|
| 25 |
+
- Sentence similarity and semantic matching.
|
| 26 |
+
- Semantic search over Luganda text.
|
| 27 |
+
- Sentence clustering and grouping.
|
| 28 |
+
- Duplicate or near-duplicate sentence exploration.
|
| 29 |
+
- Embedding-based retrieval and other downstream experiments.
|
| 30 |
+
|
| 31 |
+
These are potential application areas, not claims that the model has been evaluated or optimized for every task listed above. Retrieval quality will depend on the corpus, preprocessing, similarity strategy, and evaluation data used by the application.
|
| 32 |
+
|
| 33 |
+
## STS benchmark results
|
| 34 |
+
|
| 35 |
+
The model was evaluated on the SAGE POND Semantic Textual Similarity benchmark, [`sagepond/sts`](https://huggingface.co/datasets/sagepond/sts). The evaluation set contains approximately **282 samples**.
|
| 36 |
+
|
| 37 |
+
| Metric | Score |
|
| 38 |
+
|---|---:|
|
| 39 |
+
| Pearson correlation score | 34.06 |
|
| 40 |
+
| Spearman correlation score | 47.91 |
|
| 41 |
+
| STS score | **40.98** |
|
| 42 |
+
|
| 43 |
+
The reported STS score is the arithmetic mean of the reported Pearson and Spearman scores. The values above are shown on the same 0–100 scale as the evaluation output.
|
| 44 |
+
|
| 45 |
+
**Benchmark characteristics:** although the evaluation set is compact (approximately 282 examples), it contains notably challenging sentence pairs. Its size should not be mistaken for an indication that the examples are easy or that the score is low simply because the benchmark is small. The results reflect the model's ability to capture semantic similarity across the particular difficult examples included in `sagepond/sts`; a similarly sized but easier test set could produce substantially different scores.
|
| 46 |
+
|
| 47 |
+
These results are an initial evaluation on the SAGE POND benchmark, not evidence of broad performance across every Luganda domain. They should not be directly compared with scores from other STS datasets or evaluation protocols without checking differences in data selection, difficulty, scoring, and preprocessing. A larger and independently curated evaluation would provide a stronger estimate of generalization.
|
| 48 |
+
|
| 49 |
+
## Model details
|
| 50 |
+
|
| 51 |
+
| Property | Value |
|
| 52 |
+
|---|---|
|
| 53 |
+
| Model type | Transformer sentence encoder |
|
| 54 |
+
| Primary language | Luganda |
|
| 55 |
+
| Training data format | Sentences (not QA-style examples) |
|
| 56 |
+
| Tokenizer | SentencePiece |
|
| 57 |
+
| Vocabulary size | 40,000 tokens |
|
| 58 |
+
| Transformer layers | 12 |
|
| 59 |
+
| Hidden size | 768 |
|
| 60 |
+
| Attention heads | 16 |
|
| 61 |
+
| Feed-forward dimension | 3,072 |
|
| 62 |
+
| Maximum sequence length | 600 tokens |
|
| 63 |
+
| Sentence embedding dimension | 3,072 |
|
| 64 |
+
| Pooling | Attention-mask-aware mean pooling |
|
| 65 |
+
| Output normalization | L2 normalization |
|
| 66 |
+
|
| 67 |
+
The model adds learned positional embeddings to token embeddings, encodes the sequence with a Transformer encoder, applies masked mean pooling, and projects the pooled representation to the final 3,072-dimensional embedding space. The output embeddings are L2-normalized.
|
| 68 |
+
|
| 69 |
+
## Usage
|
| 70 |
+
|
| 71 |
+
The repository uses custom Transformers code. Load it with `trust_remote_code=True`:
|
| 72 |
+
|
| 73 |
+
```python
|
| 74 |
+
import torch
|
| 75 |
+
import torch.nn.functional as F
|
| 76 |
+
from transformers import AutoModel, AutoTokenizer
|
| 77 |
+
|
| 78 |
+
model_id = "sagepond/embedding-small"
|
| 79 |
+
|
| 80 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 81 |
+
model_id,
|
| 82 |
+
trust_remote_code=True,
|
| 83 |
+
)
|
| 84 |
+
model = AutoModel.from_pretrained(
|
| 85 |
+
model_id,
|
| 86 |
+
trust_remote_code=True,
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
model.eval()
|
| 90 |
+
|
| 91 |
+
sentences = [
|
| 92 |
+
"Ekigambo eky'okulabirako eky'Oluganda.",
|
| 93 |
+
"Sentensi endala ey'okugezesa.",
|
| 94 |
+
]
|
| 95 |
+
|
| 96 |
+
inputs = tokenizer(
|
| 97 |
+
sentences,
|
| 98 |
+
padding=True,
|
| 99 |
+
truncation=True,
|
| 100 |
+
max_length=600,
|
| 101 |
+
return_tensors="pt",
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
with torch.inference_mode():
|
| 105 |
+
embeddings = model(**inputs).pooler_output
|
| 106 |
+
|
| 107 |
+
print(embeddings.shape) # torch.Size([2, 3072])
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
Because the model returns normalized embeddings, cosine similarity can be calculated with a dot product:
|
| 111 |
+
|
| 112 |
+
```python
|
| 113 |
+
similarity = embeddings[0] @ embeddings[1]
|
| 114 |
+
print(similarity.item())
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
For a larger collection of sentences, encode texts in batches and store the resulting vectors in a vector index or another retrieval system. Use the same model and tokenizer version for both indexed documents and incoming queries.
|
| 118 |
+
|
| 119 |
+
## Limitations
|
| 120 |
+
|
| 121 |
+
- The benchmark contains approximately 282 samples, so its scores have limited statistical coverage.
|
| 122 |
+
- The model was trained on sentence-level data, not question-answer pairs. Do not assume that it is optimized for question-to-passage retrieval or QA matching without task-specific evaluation.
|
| 123 |
+
- Performance may vary across topics, writing styles, spelling variants, dialectal variation, and text domains that are not represented in the evaluation data.
|
| 124 |
+
- The 600-token maximum sequence length is a model input limit; long documents should be split into suitable chunks and embedded separately.
|
| 125 |
+
- Similarity scores are relative signals for ranking or comparison. They are not calibrated probabilities or factual confidence scores.
|
| 126 |
+
|
| 127 |
+
## Intended audience
|
| 128 |
+
|
| 129 |
+
Researchers, developers, students, and language-technology practitioners interested in experimenting with Luganda sentence embeddings, semantic similarity, and semantic retrieval.
|
| 130 |
+
|
| 131 |
+
## Dataset
|
| 132 |
+
|
| 133 |
+
The STS evaluation dataset is available at [sagepond/sts](https://huggingface.co/datasets/sagepond/sts).
|
| 134 |
+
|
| 135 |
+
## Citation and attribution
|
| 136 |
+
|
| 137 |
+
This model was developed by **SAGE POND**. When using it in research or derivative work, cite the model repository and the [`sagepond/sts`](https://huggingface.co/datasets/sagepond/sts) dataset, and report the evaluation setup used in your experiments.
|