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
Update README.md
Browse files12345612345678919 unmodified lines293031323233343535363738394041424344383940484941424344452 unmodified lines48495058515260615354555657585960---
library_name: transformers
datasets:
- bigcode/the-stack-v2
license: bigcode-openrail-m
---
---library_name: transformersdatasets:- bigcode/the-stack-v2license: bigcode-openrail-m---
# Model Card for Model ID
19 unmodified linesfrom transformers import AutoTokenizer
#import the modelmodel = AutoModel.from_pretrained("andreagurioli1995/ModularStarEncoder-finetuned", trust_remote_code=True)model = AutoModel.from_pretrained("andreagurioli1995/ModularStarEncoder", trust_remote_code=True)
#import the tokenizertokenizer = AutoTokenizer.from_pretrained("andreagurioli1995/ModularStarEncoder-finetuned")tokenizer = AutoTokenizer.from_pretrained("andreagurioli1995/ModularStarEncoder")
language = "yourlanguagelowercased"
#instruction in case of code embedding in a code languageinstruction_code = f"Represent this {language} code snippet for retrieval:"
#instruction in case of code embedding in Englishinstruction_natural_language = "Represent this code description for retrieving supporting snippets of code:"
code_snippet = "your code to embed here"
#You should follow this pattern to embed a snippet of code or natural language queries sentence = f"{tokenizer.sep_token}{instruction_code}{tokenizer.sep_token}{code_snippet)}{tokenizer.cls_token}"#You should follow this pattern to embed a snippet of code sentence = f"{tokenizer.sep_token}{code_snippet}{tokenizer.cls_token}
#Tokenizing your sentencetokenized_sensence = tokenizer(sentence, return_tensors="pt",truncation=True, max_length=2048)2 unmodified linesembedded_sentence = model(**sentence)```
You will get as an output three elements:You will get as an output six elements:
- projected_pooled_normalized: a list of the projected, pooled, and normalized embeddings from the five exit points;- raw_hidden_states: raw representation from all the hidden states of the model, without pooling, normalization, and projection- last_hidden_state: the representation of the last hidden state from the model;- hidden_states: raw representation from all the hidden states of the model, without pooling, normalization, and projection- loss: loss value if a ground truth is given (None if used in inference)- prediction_logits: prediction scores from masked language modeling head- seq_relationship_scores: prediction scores of in-context loss (concatenate multiple samples with the separator token if you want a meaningful score)- attentions: attention scores from the encoder ### Model DescriptionREADME.md+16-20