Instructions to use modularStarEncoder/ModularStarEncoder-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use modularStarEncoder/ModularStarEncoder-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="modularStarEncoder/ModularStarEncoder-finetuned", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("modularStarEncoder/ModularStarEncoder-finetuned", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files1234564 unmodified lines111213141516---library_name: transformerstags: []---# Model Card for Model ID4 unmodified lines## Model Details### Model Description<!-- Provide a longer summary of what this model is. -->123456784 unmodified lines13141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758---library_name: transformersdatasets:- bigcode/the-stack-v2license: bigcode-openrail-m---# Model Card for Model ID4 unmodified lines## Model Details### How to use```pythonfrom transformers import AutoModelfrom transformers import AutoTokenizer#import the modelmodel = AutoModel.from_pretrained("andreagurioli1995/ModularStarEncoder-finetuned", trust_remote_code=True)#import the tokenizertokenizer = AutoTokenizer.from_pretrained("andreagurioli1995/ModularStarEncoder-finetuned")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 queriessentence = f"{tokenizer.sep_token}{instruction_code}{tokenizer.sep_token}{code_snippet)}{tokenizer.cls_token}"#Tokenizing your sentencetokenized_sensence = tokenizer(sentence, return_tensors="pt",truncation=True, max_length=2048)#Embedding the tokenized sentenceembedded_sentence = model(**sentence)```You will get as an output three 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- attentions: attention scores from the encoder### Model Description<!-- Provide a longer summary of what this model is. -->
README.md+43-1