Add new SentenceTransformer model
Browse files- README.md +102 -86
- entity_embeddings.npy +1 -1
README.md
CHANGED
|
@@ -1,127 +1,143 @@
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
-
- transformers
|
| 4 |
- sentence-transformers
|
| 5 |
-
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
- bert-base-uncased
|
| 11 |
-
model_index:
|
| 12 |
-
- name: kpr-bert-base-uncased
|
| 13 |
-
results:
|
| 14 |
---
|
| 15 |
|
| 16 |
-
#
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
##
|
| 33 |
|
| 34 |
-
|
| 35 |
-
| --- | --- | --- |
|
| 36 |
-
| [knowledgeable-ai/kpr-bert-base-uncased](https://huggingface.co/knowledgeable-ai/kpr-bert-base-uncased) | 112M | [bert-base-uncased](https://huggingface.co/google-bert/bert-base-uncased) |
|
| 37 |
-
| [knowledgeable-ai/kpr-retromae](https://huggingface.co/knowledgeable-ai/kpr-retromae) | 112M | [RetroMAE](https://huggingface.co/Shitao/RetroMAE) |
|
| 38 |
-
| [knowledgeable-ai/kpr-bge-base-en](https://huggingface.co/knowledgeable-ai/kpr-bge-base-en) | 112M | [bge-base-en](https://huggingface.co/BAAI/bge-base-en) |
|
| 39 |
-
| [knowledgeable-ai/kpr-bge-base-en-v1.5](https://huggingface.co/knowledgeable-ai/kpr-bge-base-en-v1.5) | 112M | [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) |
|
| 40 |
-
| [knowledgeable-ai/kpr-bge-large-en-v1.5](https://huggingface.co/knowledgeable-ai/kpr-bge-large-en-v1.5) | 340M | [bge-large-en-v1.5](https://huggingface.co/BAAI/bge-large-en-v1.5) |
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
|
|
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
import torch
|
| 62 |
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
-
"Who founded Dominican Liberation Party?",
|
| 67 |
-
"Who owns Mompesson House?"
|
| 68 |
-
]
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
model = AutoModel.from_pretrained(MODEL_NAME_OR_PATH, trust_remote_code=True)
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
embeddings = model.encode(**preprocessed_inputs)
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
|
|
|
| 90 |
|
| 91 |
-
|
| 92 |
-
"Who founded Dominican Liberation Party?",
|
| 93 |
-
"Who owns Mompesson House?"
|
| 94 |
-
]
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
| 100 |
-
embeddings = model.encode(input_texts)
|
| 101 |
|
| 102 |
-
|
| 103 |
-
```
|
| 104 |
|
| 105 |
-
|
|
|
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
```
|
| 110 |
|
| 111 |
-
|
|
|
|
| 112 |
|
| 113 |
-
|
|
|
|
| 114 |
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
```bibtex
|
| 121 |
-
@article{yamada2025kpr,
|
| 122 |
-
title={Dynamic Injection of Entity Knowledge into Dense Retrievers},
|
| 123 |
-
author={Ikuya Yamada and Ryokan Ri and Takeshi Kojima and Yusuke Iwasawa and Yutaka Matsuo},
|
| 124 |
-
journal={arXiv preprint arXiv:2507.03922},
|
| 125 |
-
year={2025}
|
| 126 |
-
}
|
| 127 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
|
|
|
| 3 |
- sentence-transformers
|
| 4 |
+
- sentence-similarity
|
| 5 |
+
- feature-extraction
|
| 6 |
+
- dense
|
| 7 |
+
pipeline_tag: sentence-similarity
|
| 8 |
+
library_name: sentence-transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# SentenceTransformer
|
| 12 |
|
| 13 |
+
This is a [sentence-transformers](https://www.SBERT.net) model trained. It maps sentences & 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.
|
| 14 |
|
| 15 |
+
## Model Details
|
| 16 |
|
| 17 |
+
### Model Description
|
| 18 |
+
- **Model Type:** Sentence Transformer
|
| 19 |
+
<!-- - **Base model:** [Unknown](https://huggingface.co/unknown) -->
|
| 20 |
+
- **Maximum Sequence Length:** 512 tokens
|
| 21 |
+
- **Output Dimensionality:** 768 dimensions
|
| 22 |
+
- **Similarity Function:** Dot Product
|
| 23 |
+
<!-- - **Training Dataset:** Unknown -->
|
| 24 |
+
<!-- - **Language:** Unknown -->
|
| 25 |
+
<!-- - **License:** Unknown -->
|
| 26 |
|
| 27 |
+
### Model Sources
|
| 28 |
|
| 29 |
+
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
| 30 |
+
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
|
| 31 |
+
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
|
| 32 |
|
| 33 |
+
### Full Model Architecture
|
| 34 |
|
| 35 |
+
```
|
| 36 |
+
SentenceTransformer(
|
| 37 |
+
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'KPRModelForBert'})
|
| 38 |
+
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
| 39 |
+
)
|
| 40 |
+
```
|
| 41 |
|
| 42 |
+
## Usage
|
| 43 |
|
| 44 |
+
### Direct Usage (Sentence Transformers)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
First install the Sentence Transformers library:
|
| 47 |
|
| 48 |
+
```bash
|
| 49 |
+
pip install -U sentence-transformers
|
| 50 |
+
```
|
| 51 |
|
| 52 |
+
Then you can load this model and run inference.
|
| 53 |
+
```python
|
| 54 |
+
from sentence_transformers import SentenceTransformer
|
| 55 |
|
| 56 |
+
# Download from the 🤗 Hub
|
| 57 |
+
model = SentenceTransformer("knowledgeable-ai/kpr-bert-base-uncased")
|
| 58 |
+
# Run inference
|
| 59 |
+
sentences = [
|
| 60 |
+
'The weather is lovely today.',
|
| 61 |
+
"It's so sunny outside!",
|
| 62 |
+
'He drove to the stadium.',
|
| 63 |
+
]
|
| 64 |
+
embeddings = model.encode(sentences)
|
| 65 |
+
print(embeddings.shape)
|
| 66 |
+
# [3, 768]
|
| 67 |
+
|
| 68 |
+
# Get the similarity scores for the embeddings
|
| 69 |
+
similarities = model.similarity(embeddings, embeddings)
|
| 70 |
+
print(similarities)
|
| 71 |
+
# tensor([[743.6603, 712.7500, 674.8392],
|
| 72 |
+
# [712.7500, 743.7998, 678.3881],
|
| 73 |
+
# [674.8391, 678.3880, 743.6827]])
|
| 74 |
+
```
|
| 75 |
|
| 76 |
+
<!--
|
| 77 |
+
### Direct Usage (Transformers)
|
| 78 |
|
| 79 |
+
<details><summary>Click to see the direct usage in Transformers</summary>
|
| 80 |
|
| 81 |
+
</details>
|
| 82 |
+
-->
|
| 83 |
|
| 84 |
+
<!--
|
| 85 |
+
### Downstream Usage (Sentence Transformers)
|
|
|
|
| 86 |
|
| 87 |
+
You can finetune this model on your own dataset.
|
| 88 |
|
| 89 |
+
<details><summary>Click to expand</summary>
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
</details>
|
| 92 |
+
-->
|
|
|
|
| 93 |
|
| 94 |
+
<!--
|
| 95 |
+
### Out-of-Scope Use
|
| 96 |
|
| 97 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 98 |
+
-->
|
|
|
|
| 99 |
|
| 100 |
+
<!--
|
| 101 |
+
## Bias, Risks and Limitations
|
| 102 |
|
| 103 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 104 |
+
-->
|
| 105 |
|
| 106 |
+
<!--
|
| 107 |
+
### Recommendations
|
| 108 |
|
| 109 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
| 110 |
+
-->
|
| 111 |
|
| 112 |
+
## Training Details
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
+
### Framework Versions
|
| 115 |
+
- Python: 3.10.14
|
| 116 |
+
- Sentence Transformers: 5.2.0.dev0
|
| 117 |
+
- Transformers: 4.55.4
|
| 118 |
+
- PyTorch: 2.4.0+cu121
|
| 119 |
+
- Accelerate: 0.34.2
|
| 120 |
+
- Datasets: 2.16.1
|
| 121 |
+
- Tokenizers: 0.21.4
|
| 122 |
|
| 123 |
+
## Citation
|
|
|
|
| 124 |
|
| 125 |
+
### BibTeX
|
|
|
|
| 126 |
|
| 127 |
+
<!--
|
| 128 |
+
## Glossary
|
| 129 |
|
| 130 |
+
*Clearly define terms in order to be accessible across audiences.*
|
| 131 |
+
-->
|
|
|
|
| 132 |
|
| 133 |
+
<!--
|
| 134 |
+
## Model Card Authors
|
| 135 |
|
| 136 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
| 137 |
+
-->
|
| 138 |
|
| 139 |
+
<!--
|
| 140 |
+
## Model Card Contact
|
| 141 |
|
| 142 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
| 143 |
+
-->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity_embeddings.npy
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 11126965376
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7ac70ec87164d457b56b081b9022deff06cd8dd19d74ade2655fe5154e5ad52b
|
| 3 |
size 11126965376
|