Instructions to use modularStarEncoder/ModularStarEncoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use modularStarEncoder/ModularStarEncoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="modularStarEncoder/ModularStarEncoder", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("modularStarEncoder/ModularStarEncoder", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload ModularStarEncoder
Browse files12348 unmodified lines1314151617181914 unmodified lines34353637383940414238 unmodified lines81828384858687161 unmodified lines249250251252253254255256257258259from transformers import AutoConfig, Starcoder2Model, Starcoder2Configimport sysfrom config import ModularStarEncoderConfigimport os8 unmodified linesfrom transformers.modeling_utils import PreTrainedModelfrom transformers.utils import (ModelOutput,logging,)14 unmodified lines_supports_sdpa = True_supports_cache_class = True# def __init__(self):# self._supports_flash_attn_2 = True# super().__init__()def _init_weights(self, module):38 unmodified linesprediction_logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).seq_relationship_logits (`torch.FloatTensor` of shape `(batch_size, 2)`):Prediction scores of the next sequence prediction (classification) head (scores of True/False continuationbefore SoftMax).hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of161 unmodified linesconfig.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are ignored (masked),the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`next_sentence_label (`torch.LongTensor` of shape `(batch_size,)`, *optional*):Labels for computing the next sequence prediction (classification) loss. Input should be a sequencepair (see `input_ids` docstring) Indices should be in `[0, 1]`:- 0 indicates sequence B is a continuation of sequence A,- 1 indicates sequence B is a random sequence.kwargs (`Dict[str, any]`, optional, defaults to *{}*):Used to hide legacy arguments that have been deprecated.12348 unmodified lines13141516171814 unmodified lines33343536373838 unmodified lines77787980818283161 unmodified lines245246247248249250251252253from transformers import Starcoder2Modelimport sysfrom config import ModularStarEncoderConfigimport os8 unmodified linesfrom transformers.modeling_utils import PreTrainedModelfrom transformers.utils import (ModelOutput,logging,)14 unmodified lines_supports_sdpa = True_supports_cache_class = Truedef _init_weights(self, module):38 unmodified linesprediction_logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).seq_relationship_logits (`torch.FloatTensor` of shape `(batch_size, 2)`):Prediction scores of the in context classification (classification) head (scores of True/False continuationbefore SoftMax).hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of161 unmodified linesconfig.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are ignored (masked),the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`next_sentence_label (`torch.LongTensor` of shape `(batch_size,)`, *optional*):This label is assigned to the in context loss:- 0 indicates sequence B belongs to the same repository of A,- 1 indicates sequence B is a random repository.kwargs (`Dict[str, any]`, optional, defaults to *{}*):Used to hide legacy arguments that have been deprecated.
modularStarEncoder.py+5-11