Sentence Similarity
sentence-transformers
Safetensors
English
ultrabert
feature-extraction
mteb
long-context
custom_code
Eval Results (legacy)
Instructions to use PhysShell/UltraBERT-Embed-150M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use PhysShell/UltraBERT-Embed-150M with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("PhysShell/UltraBERT-Embed-150M", trust_remote_code=True) 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
Download configuration_ultrabert.py from PhysShell/UltraBERT-Embed-150M: direct link, hf CLI and curl.
- Browser
- Download file 2.21 kB
-
https://huggingface.co/PhysShell/UltraBERT-Embed-150M/resolve/main/configuration_ultrabert.py
- Command line
-
hf download hf://PhysShell/UltraBERT-Embed-150M/configuration_ultrabert.py
-
curl -L -o configuration_ultrabert.py https://huggingface.co/PhysShell/UltraBERT-Embed-150M/resolve/main/configuration_ultrabert.py
2.21 kB
| from __future__ import annotations | |
| from collections.abc import Iterable | |
| from transformers.configuration_utils import PretrainedConfig | |
| class UltrabertConfig(PretrainedConfig): | |
| model_type = "ultrabert" | |
| def __init__( | |
| self, | |
| vocab_size=32000, | |
| hidden_size=4096, | |
| intermediate_size=11008, | |
| prediction_head_size=None, | |
| num_hidden_layers=32, | |
| num_attention_heads=32, | |
| num_key_value_heads=None, | |
| attention_windows=None, | |
| hidden_act="silu", | |
| initializer_range=0.02, | |
| rms_norm_eps=1e-6, | |
| pad_token_id=0, | |
| bos_token_id=0, | |
| eos_token_id=0, | |
| tie_word_embeddings=False, | |
| rope_theta=10000.0, | |
| attention_bias=False, | |
| attention_dropout=0.0, | |
| mlp_bias=False, | |
| head_dim=None, | |
| classifier_dropout=0.0, | |
| **kwargs, | |
| ): | |
| super().__init__( | |
| pad_token_id=pad_token_id, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| tie_word_embeddings=tie_word_embeddings, | |
| **kwargs, | |
| ) | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.intermediate_size = intermediate_size | |
| self.prediction_head_size = prediction_head_size | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_attention_heads = num_attention_heads | |
| self.num_key_value_heads = num_key_value_heads or num_attention_heads | |
| self.attention_windows = ( | |
| attention_windows | |
| if isinstance(attention_windows, Iterable) | |
| else [attention_windows] * num_hidden_layers | |
| ) | |
| self.hidden_act = hidden_act | |
| self.initializer_range = initializer_range | |
| self.rms_norm_eps = rms_norm_eps | |
| self.rope_theta = ( | |
| rope_theta | |
| if isinstance(rope_theta, Iterable) | |
| else [rope_theta] * num_hidden_layers | |
| ) | |
| self.attention_bias = attention_bias | |
| self.attention_dropout = attention_dropout | |
| self.mlp_bias = mlp_bias | |
| self.head_dim = head_dim or self.hidden_size // self.num_attention_heads | |
| self.classifier_dropout = classifier_dropout | |