Downloads · 30 days
84
21% of all-time downloads
ZhishanQ/UniHGKR-base-beir
UniHGKR-base-beir is a sentence similarity model from ZhishanQ. Use it when you need a score for how close two texts are. It is set up for sentence-transformers.
Our paper: UniHGKR: Unified Instruction-aware Heterogeneous Knowledge Retrievers.
Downloads · 30 days
84
21% of all-time downloads
All-time downloads
395
Public
Parameters
109M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
Our paper: UniHGKR: Unified Instruction-aware Heterogeneous Knowledge Retrievers.
The UniHGKR-base-beir model is derived from the UniHGKR-base model, further fine-tuned on MS MARCO for evaluation on the BEIR benchmark. We recommend using the sentence-transformers package to load our model and to perform embedding for paragraphs and sentences.
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.
The evaluation code can be found at https://github.com/ZhishanQ/UniHGKR.
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
(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})
(2): Normalize()
)
Use the instructions to achieve the best performance from the model:
general_ins = "Given a question, retrieve relevant evidence that can answer the question from all knowledge sources:"
single_source_inst = "Given a question, retrieve relevant evidence that can answer the question from Text sources:"
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("ZhishanQ/UniHGKR-base-beir")
# Run inference
general_ins = "Given a question, retrieve relevant evidence that can answer the question from all knowledge sources:"
single_source_inst = "Given a question, retrieve relevant evidence that can answer the question from Text sources:"
sentences = [
'The weather is lovely today.',
"It's so sunny outside!",
'He drove to the stadium.',
]
# Prepend each sentence with the instruction
updated_sentences = [f"{single_source_inst} {sentence}" for sentence in sentences]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
<!--
### Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details>
-->
<!--
### Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details>
-->
<!--
### Out-of-Scope Use
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->
<!--
## Bias, Risks and Limitations
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
-->
<!--
### Recommendations
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
-->
If you find this resource useful in your research, please consider giving a like and citation.
@article{min2024unihgkr,
title={UniHGKR: Unified Instruction-aware Heterogeneous Knowledge Retrievers},
author={Min, Dehai and Xu, Zhiyang and Qi, Guilin and Huang, Lifu and You, Chenyu},
journal={arXiv preprint arXiv:2410.20163},
year={2024}
}
<!--
## Glossary
*Clearly define terms in order to be accessible across audiences.*
-->
<!--
## Model Card Authors
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->
<!--
## Model Card Contact
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->