Text Retrieval
Transformers
Safetensors
sentence-transformers
English
kpr-bert
feature-extraction
custom_code
Instructions to use knowledgeable-ai/kpr-bge-base-en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use knowledgeable-ai/kpr-bge-base-en with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("knowledgeable-ai/kpr-bge-base-en", trust_remote_code=True, device_map="auto") - sentence-transformers
How to use knowledgeable-ai/kpr-bge-base-en with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("knowledgeable-ai/kpr-bge-base-en", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Download configuration.py from knowledgeable-ai/kpr-bge-base-en: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/knowledgeable-ai/kpr-bge-base-en/resolve/main/configuration.py
- Command line
-
hf download hf://knowledgeable-ai/kpr-bge-base-en/configuration.py
-
curl -L -o configuration.py https://huggingface.co/knowledgeable-ai/kpr-bge-base-en/resolve/main/configuration.py
1.28 kB
| from transformers.models.bert import BertConfig | |
| from transformers.models.xlm_roberta import XLMRobertaConfig | |
| def _init_function( | |
| self, | |
| entity_vocab_size: int | None = 10000, | |
| entity_embedding_size: int = 768, | |
| entity_fusion_method: str = "multihead_attention", | |
| use_entity_position_embeddings: bool = True, | |
| entity_fusion_activation: str = "softmax", | |
| num_entity_fusion_attention_heads: int = 12, | |
| similarity_function: str = "dot", | |
| similarity_temperature: float = 1.0, | |
| *args, | |
| **kwargs, | |
| ): | |
| self.entity_vocab_size = entity_vocab_size | |
| self.entity_embedding_size = entity_embedding_size | |
| self.entity_fusion_method = entity_fusion_method | |
| self.use_entity_position_embeddings = use_entity_position_embeddings | |
| self.entity_fusion_activation = entity_fusion_activation | |
| self.num_entity_fusion_attention_heads = num_entity_fusion_attention_heads | |
| self.similarity_function = similarity_function | |
| self.similarity_temperature = similarity_temperature | |
| super(self.__class__, self).__init__(*args, **kwargs) | |
| class KPRConfigForBert(BertConfig): | |
| __init__ = _init_function | |
| model_type = "kpr-bert" | |
| class KPRConfigForXLMRoberta(XLMRobertaConfig): | |
| __init__ = _init_function | |
| model_type = "kpr-xlm-roberta" | |