Sentence Similarity
sentence-transformers
Safetensors
English
modernbert
feature-extraction
dense
text-embeddings-inference
🇪🇺 Region: EU
Instructions to use lightonai/DenseOn-unsupervised with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use lightonai/DenseOn-unsupervised with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("lightonai/DenseOn-unsupervised") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Update README.md
#1
by paulomouraj - opened
README.md
CHANGED
|
@@ -6,23 +6,46 @@ tags:
|
|
| 6 |
- dense
|
| 7 |
pipeline_tag: sentence-similarity
|
| 8 |
library_name: sentence-transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
## Model Details
|
| 16 |
|
| 17 |
### Model Description
|
| 18 |
- **Model Type:** Sentence Transformer
|
| 19 |
-
|
| 20 |
- **Maximum Sequence Length:** 512 tokens
|
| 21 |
- **Output Dimensionality:** 768 dimensions
|
| 22 |
- **Similarity Function:** Cosine Similarity
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
### Model Sources
|
| 28 |
|
|
@@ -53,63 +76,37 @@ Then you can load this model and run inference.
|
|
| 53 |
```python
|
| 54 |
from sentence_transformers import SentenceTransformer
|
| 55 |
|
| 56 |
-
# Download from the
|
| 57 |
-
model = SentenceTransformer("lightonai/
|
|
|
|
| 58 |
# Run inference
|
| 59 |
queries = [
|
| 60 |
"Which planet is known as the Red Planet?",
|
| 61 |
]
|
| 62 |
documents = [
|
| 63 |
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 64 |
-
|
| 65 |
-
|
| 66 |
]
|
| 67 |
-
|
| 68 |
-
|
|
|
|
| 69 |
print(query_embeddings.shape, document_embeddings.shape)
|
| 70 |
# [1, 768] [3, 768]
|
| 71 |
|
| 72 |
# Get the similarity scores for the embeddings
|
| 73 |
similarities = model.similarity(query_embeddings, document_embeddings)
|
| 74 |
print(similarities)
|
| 75 |
-
# tensor([[0.3464, 0.4823, 0.5147]])
|
| 76 |
```
|
| 77 |
|
| 78 |
-
|
| 79 |
-
### Direct Usage (Transformers)
|
| 80 |
-
|
| 81 |
-
<details><summary>Click to see the direct usage in Transformers</summary>
|
| 82 |
-
|
| 83 |
-
</details>
|
| 84 |
-
-->
|
| 85 |
-
|
| 86 |
-
<!--
|
| 87 |
-
### Downstream Usage (Sentence Transformers)
|
| 88 |
-
|
| 89 |
-
You can finetune this model on your own dataset.
|
| 90 |
-
|
| 91 |
-
<details><summary>Click to expand</summary>
|
| 92 |
-
|
| 93 |
-
</details>
|
| 94 |
-
-->
|
| 95 |
-
|
| 96 |
-
<!--
|
| 97 |
-
### Out-of-Scope Use
|
| 98 |
-
|
| 99 |
-
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 100 |
-
-->
|
| 101 |
-
|
| 102 |
-
<!--
|
| 103 |
-
## Bias, Risks and Limitations
|
| 104 |
-
|
| 105 |
-
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 106 |
-
-->
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
*
|
| 112 |
-
|
|
|
|
| 113 |
|
| 114 |
## Training Details
|
| 115 |
|
|
@@ -128,11 +125,12 @@ You can finetune this model on your own dataset.
|
|
| 128 |
|
| 129 |
```bibtex
|
| 130 |
@misc{sourty2025denseonlateon,
|
| 131 |
-
title={DenseOn
|
| 132 |
-
author={Sourty,
|
| 133 |
year={2026},
|
| 134 |
howpublished={\url{https://huggingface.co/blog/lightonai/denseon-lateon}},
|
| 135 |
}
|
|
|
|
| 136 |
```
|
| 137 |
|
| 138 |
```bibtex
|
|
@@ -161,6 +159,24 @@ You can finetune this model on your own dataset.
|
|
| 161 |
}
|
| 162 |
```
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
<!--
|
| 165 |
## Glossary
|
| 166 |
|
|
|
|
| 6 |
- dense
|
| 7 |
pipeline_tag: sentence-similarity
|
| 8 |
library_name: sentence-transformers
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
language:
|
| 11 |
+
- en
|
| 12 |
+
base_model:
|
| 13 |
+
- answerdotai/ModernBERT-base
|
| 14 |
---
|
| 15 |
|
| 16 |
+
<p align="center">
|
| 17 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/609bbe2f4932693ca2009d6a/kbQOAarw0eaApow3M9HIl.png" alt="LightOn" width="512">
|
| 18 |
+
</p>
|
| 19 |
|
| 20 |
+
<h1 align="center">DenseOn-unsupervised</h1>
|
| 21 |
+
|
| 22 |
+
<h3 align="center">Unsupervised contrastive pre-training checkpoint by LightOn</h3>
|
| 23 |
+
|
| 24 |
+
<p align="center">
|
| 25 |
+
<a href="https://huggingface.co/lightonai/DenseOn">DenseOn</a> |
|
| 26 |
+
<a href="https://huggingface.co/lightonai/LateOn">LateOn</a> |
|
| 27 |
+
<a href="https://github.com/lightonai/pylate">PyLate</a> |
|
| 28 |
+
<a href="https://github.com/lightonai/fast-plaid">FastPLAID</a>
|
| 29 |
+
</p>
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
**DenseOn-unsupervised** is an unsupervised contrastive pre-training checkpoint built on ModernBERT (149M parameters), trained by [LightOn](https://lighton.ai). It serves as the foundation for building [DenseOn](https://huggingface.co/lightonai/DenseOn), a dense (single-vector) retrieval model that encodes queries and documents independently using cosine similarity with `query:`/`document:` prefixes and CLS pooling.
|
| 34 |
+
|
| 35 |
+
For the final dense retrieval model, use [DenseOn](https://huggingface.co/lightonai/DenseOn), which adds supervised fine-tuning with mined hard negatives on top of this checkpoint. See our [blog post](TODO) for full results and analysis.
|
| 36 |
|
| 37 |
## Model Details
|
| 38 |
|
| 39 |
### Model Description
|
| 40 |
- **Model Type:** Sentence Transformer
|
| 41 |
+
- **Base model:** [ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) (149M parameters)
|
| 42 |
- **Maximum Sequence Length:** 512 tokens
|
| 43 |
- **Output Dimensionality:** 768 dimensions
|
| 44 |
- **Similarity Function:** Cosine Similarity
|
| 45 |
+
- **Pooling:** CLS token
|
| 46 |
+
- **Prompts:** `query:` for queries, `document:` for documents
|
| 47 |
+
- **Language:** English
|
| 48 |
+
- **License:** Apache 2.0
|
| 49 |
|
| 50 |
### Model Sources
|
| 51 |
|
|
|
|
| 76 |
```python
|
| 77 |
from sentence_transformers import SentenceTransformer
|
| 78 |
|
| 79 |
+
# Download from the Hub
|
| 80 |
+
model = SentenceTransformer("lightonai/DenseOn-unsupervised")
|
| 81 |
+
|
| 82 |
# Run inference
|
| 83 |
queries = [
|
| 84 |
"Which planet is known as the Red Planet?",
|
| 85 |
]
|
| 86 |
documents = [
|
| 87 |
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 88 |
+
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
|
| 89 |
+
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
|
| 90 |
]
|
| 91 |
+
|
| 92 |
+
query_embeddings = model.encode(queries, prompt_name="query")
|
| 93 |
+
document_embeddings = model.encode(documents, prompt_name="document")
|
| 94 |
print(query_embeddings.shape, document_embeddings.shape)
|
| 95 |
# [1, 768] [3, 768]
|
| 96 |
|
| 97 |
# Get the similarity scores for the embeddings
|
| 98 |
similarities = model.similarity(query_embeddings, document_embeddings)
|
| 99 |
print(similarities)
|
|
|
|
| 100 |
```
|
| 101 |
|
| 102 |
+
## Related Models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
+
| Model | Description | Link |
|
| 105 |
+
|-------|-------------|------|
|
| 106 |
+
| **DenseOn** | Supervised dense model | [lightonai/DenseOn](https://huggingface.co/lightonai/DenseOn) |
|
| 107 |
+
| **DenseOn-unsupervised** | Pre-training-only checkpoint (this model) | [lightonai/DenseOn-unsupervised](https://huggingface.co/lightonai/DenseOn-unsupervised) |
|
| 108 |
+
| **LateOn** | Supervised ColBERT model | [lightonai/LateOn](https://huggingface.co/lightonai/LateOn) |
|
| 109 |
+
| **LateOn-unsupervised** | Pre-training-only checkpoint | [lightonai/LateOn-unsupervised](https://huggingface.co/lightonai/LateOn-unsupervised) |
|
| 110 |
|
| 111 |
## Training Details
|
| 112 |
|
|
|
|
| 125 |
|
| 126 |
```bibtex
|
| 127 |
@misc{sourty2025denseonlateon,
|
| 128 |
+
title={DenseOn with LateOn: Open State-of-the-Art Single and Multi-Vector Models},
|
| 129 |
+
author={Sourty, Raphael and Chaffin, Antoine and Weller, Orion and Moura Junior, Paulo Roberto and Chatelain, Amelie},
|
| 130 |
year={2026},
|
| 131 |
howpublished={\url{https://huggingface.co/blog/lightonai/denseon-lateon}},
|
| 132 |
}
|
| 133 |
+
|
| 134 |
```
|
| 135 |
|
| 136 |
```bibtex
|
|
|
|
| 159 |
}
|
| 160 |
```
|
| 161 |
|
| 162 |
+
<!--
|
| 163 |
+
### Out-of-Scope Use
|
| 164 |
+
|
| 165 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 166 |
+
-->
|
| 167 |
+
|
| 168 |
+
<!--
|
| 169 |
+
## Bias, Risks and Limitations
|
| 170 |
+
|
| 171 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 172 |
+
-->
|
| 173 |
+
|
| 174 |
+
<!--
|
| 175 |
+
### Recommendations
|
| 176 |
+
|
| 177 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
| 178 |
+
-->
|
| 179 |
+
|
| 180 |
<!--
|
| 181 |
## Glossary
|
| 182 |
|