Views
No views yet
1from transformers import AutoModel
2from transformers import AutoTokenizer
3
4#import the model
5model = AutoModel.from_pretrained("andreagurioli1995/ModularStarEncoder", trust_remote_code=True)
6
7#import the tokenizer, the tokenizer applies LEFT padding!
8tokenizer = AutoTokenizer.from_pretrained("andreagurioli1995/ModularStarEncoder")
9
10
11
12code_snippet = "your code to embed here"
13
14#You should follow this pattern to embed a snippet of code
15sentence = f"{tokenizer.sep_token}{code_snippet}{tokenizer.cls_token}"
16
17#Tokenizing your sentence
18tokenized_sensence = tokenizer(sentence, return_tensors="pt",truncation=True, max_length=2048)
19
20#Embedding the tokenized sentence
21embedded_sentence = model(**tokenized_sensence)| Hyperparameter | Value |
|---|---|
| Hidden size | 1024 |
| Max. position embeddings | 2048 |
| Num. of attention heads | 12 |
| Num. of key values heads | 4 |
| Num. of hidden layers | 36 |
| Attention | GQA |
| Num. of parameters | ≈1B |
| Training tokens | ≈1T |
| Loss function | MLM + In-Context loss |
| Multi-layer loss | yes |
@article{gurioli2025mosehierarchicalselfdistillationenhances,
title={MoSE: Hierarchical Self-Distillation Enhances Early Layer Embeddings},
author={Andrea Gurioli and Federico Pennino and João Monteiro and Maurizio Gabbrielli},
year={2025},
eprint={2503.03008},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2503.03008},
}