Sentence Similarity
sentence-transformers
Safetensors
xlm-roberta
feature-extraction
Generated from Trainer
dataset_size:199321
loss:CachedInfonce
custom_code
text-embeddings-inference
Instructions to use Jrinky/final_stage1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Jrinky/final_stage1 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Jrinky/final_stage1", trust_remote_code=True) sentences = [ "What organization is the person excited about donating to", "The superiority of Balcomy, next to Crail, Fife, in 1394 was possessed by Nicholas de Hay, and on 15 January that year it passed to David Lindsay of Carnbie. indicating that George Lauder only held Balcomy by hereditary feu.", "However, Robertson pulled out of the bout citing injury and was replaced by Tim Means. He lost the back and forth fight via submission in the third round. Sullivan was expected to face Marcio Alexandre Jr. on July 12, 2015, at The Ultimate Fighter 21 Finale. However, Alexandre pulled out of the fight during the week leading up to the event citing a rib injury and was replaced by promotional newcomer Dominic Waters. Sullivan won the one-sided fight via unanimous decision. Sullivan faced Alexander Yakovlev at UFC on Fox 18 on January 30, 2016. He lost the fight via knockout in the first round.", "I am super excited about donating to the ASPCA, I really wish I had the financial means to be part of their monthly donation club. In my last post I mentioned some charms I made for some friends, one a loyal customer at my shop." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
| from typing import Any, Dict, List, Optional, Union | |
| import torch | |
| from transformers import PretrainedConfig | |
| class XLMRobertaFlashConfig(PretrainedConfig): | |
| model_type = "xlm-roberta" | |
| def __init__( | |
| self, | |
| vocab_size: int = 250002, | |
| hidden_size: int = 1024, | |
| num_hidden_layers: int = 24, | |
| num_attention_heads: int = 16, | |
| intermediate_size: int = 4096, | |
| hidden_act: str = "gelu", | |
| hidden_dropout_prob: float = 0.1, | |
| attention_probs_dropout_prob: float = 0.1, | |
| max_position_embeddings: int = 8194, | |
| type_vocab_size: int = 1, | |
| initializer_range: float = 0.02, | |
| layer_norm_eps: float = 1e-05, | |
| pad_token_id: int = 1, | |
| bos_token_id: int = 0, | |
| eos_token_id: int = 2, | |
| position_embedding_type: str = "rotary", | |
| rotary_emb_base: float = 10000.0, | |
| use_cache: bool = True, | |
| use_reentrant: bool = False, | |
| classifier_dropout: Optional[float] = None, | |
| lora_adaptations: Optional[List[str]] = None, | |
| task_instructions: Optional[Dict[str, str]] = None, | |
| lora_rank: int = 4, | |
| lora_dropout_p: float = 0.0, | |
| lora_alpha: int = 1, | |
| lora_main_params_trainable: bool = False, | |
| load_trained_adapters: bool = False, | |
| use_flash_attn: bool = True, | |
| torch_dtype: Optional[Union[str, torch.dtype]] = None, | |
| emb_pooler: Optional[str] = None, | |
| matryoshka_dimensions: Optional[List[int]] = None, | |
| truncate_dim: Optional[int] = None, | |
| **kwargs: Dict[str, Any], | |
| ): | |
| """ | |
| Initialize the XLMRobertaFlashConfig configuration. | |
| Args: | |
| vocab_size (int): Size of the vocabulary. | |
| hidden_size (int): Dimensionality of the encoder layers and the pooler layer. | |
| num_hidden_layers (int): Number of hidden layers in the Transformer encoder. | |
| num_attention_heads (int): Number of attention heads for each attention layer in the Transformer encoder. | |
| intermediate_size (int): Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer. | |
| hidden_act (str): The activation function to use. | |
| hidden_dropout_prob (float): The dropout probability for all fully connected layers in the embeddings, encoder, and pooler. | |
| attention_probs_dropout_prob (float): The dropout ratio for the attention probabilities. | |
| max_position_embeddings (int): The maximum length of the position embeddings. | |
| type_vocab_size (int): The vocabulary size of the token type ids. | |
| initializer_range (float): The standard deviation for initializing all weight matrices. | |
| layer_norm_eps (float): The epsilon used by the layer normalization layers. | |
| pad_token_id (int): The ID of the padding token. | |
| bos_token_id (int): The ID of the beginning-of-sequence token. | |
| eos_token_id (int): The ID of the end-of-sequence token. | |
| position_embedding_type (str): Type of position embeddings. Options are 'absolute', 'alibi', or 'rotary'. | |
| rotary_emb_base (float): Base for rotary embeddings. | |
| use_cache (bool): Whether or not the model should return the last key/values attentions (not used by all models). | |
| use_reentrant (bool): Whether or not the model should enable the 'use_reentrant' flag in gradient checkpointing. | |
| classifier_dropout (Optional[float]): The dropout ratio for the classification head. | |
| lora_adaptations (Optional[List[str]]): LoRA adaptations configuration. | |
| lora_prompts (Optional[Dict[str, str]]): LoRA prompts configuration. | |
| lora_rank (int): Rank for LoRA adaptations. | |
| lora_dropout_p (float): Dropout probability for LoRA adaptations. | |
| lora_alpha (int): Alpha parameter for LoRA. | |
| lora_main_params_trainable (bool): Whether to make the main model parameters trainable when using LoRA. | |
| load_trained_adapters (bool): Whether to load trained adapters. | |
| use_flash_attn (bool): Whether to use FlashAttention. | |
| torch_dtype (Optional[Union[str, torch.dtype]]): Data type for the tensors. | |
| emb_pooler (Optional[str]): Pooling layer configuration. | |
| matryoshka_dimensions (Optional[List[int]]): Configuration for matryoshka dimension reduction. | |
| truncate_dim (Optional[int]): Dimension to truncate embeddings to, if any. | |
| **kwargs (Dict[str, Any]): Additional keyword arguments passed to the configuration. | |
| """ | |
| super().__init__( | |
| pad_token_id=pad_token_id, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| **kwargs, | |
| ) | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_attention_heads = num_attention_heads | |
| self.hidden_act = hidden_act | |
| self.intermediate_size = intermediate_size | |
| self.hidden_dropout_prob = hidden_dropout_prob | |
| self.attention_probs_dropout_prob = attention_probs_dropout_prob | |
| self.max_position_embeddings = max_position_embeddings | |
| self.type_vocab_size = type_vocab_size | |
| self.initializer_range = initializer_range | |
| self.layer_norm_eps = layer_norm_eps | |
| self.position_embedding_type = position_embedding_type | |
| self.rotary_emb_base = rotary_emb_base | |
| self.use_cache = use_cache | |
| self.use_reentrant = use_reentrant | |
| self.classifier_dropout = classifier_dropout | |
| self.load_trained_adapters = load_trained_adapters | |
| self.lora_adaptations = lora_adaptations | |
| self.task_instructions = task_instructions | |
| self.lora_rank = lora_rank | |
| self.lora_dropout_p = lora_dropout_p | |
| self.lora_alpha = lora_alpha | |
| self.lora_main_params_trainable = lora_main_params_trainable | |
| self.use_flash_attn = use_flash_attn | |
| self.emb_pooler = emb_pooler | |
| self.matryoshka_dimensions = matryoshka_dimensions | |
| self.truncate_dim = truncate_dim | |
| if ( | |
| torch_dtype | |
| and hasattr(torch, torch_dtype) | |
| and type(getattr(torch, torch_dtype)) is torch.dtype | |
| ): | |
| self.torch_dtype = getattr(torch, torch_dtype) | |
| else: | |
| self.torch_dtype = torch_dtype | |
| if not self.use_flash_attn or not torch.cuda.is_available(): | |
| self.torch_dtype = torch.float32 |