Update README.md
Browse files10 unmodified lines1112131415161718192021222324252627282930313233343536373839404142434410 unmodified lines555657585960616263646566676869707172737475767778798081828310 unmodified linesresults: []---<!-- This model card has been generated automatically according to the information the Trainer had access to. Youshould probably proofread and complete it, then remove this comment. --># stack-edu-classifier-javascriptThis model is a fine-tuned version of [bigcode/starencoder](https://huggingface.co/bigcode/starencoder) on an unknown dataset.It achieves the following results on the evaluation set:- Loss: 0.3612- Precision: 0.5135- Recall: 0.3322- F1 Macro: 0.3711- Accuracy: 0.6277- F1 Binary Minimum3: 0.5704## Model descriptionMore information needed## Intended uses & limitationsMore information needed## Training and evaluation dataMore information needed## Training procedure### Training hyperparametersThe following hyperparameters were used during training:10 unmodified lines- lr_scheduler_warmup_steps: 200- num_epochs: 20### Training results| Training Loss | Epoch | Step | Validation Loss | Precision | Recall | F1 Macro | Accuracy | F1 Binary Minimum3 ||:-------------:|:-------:|:-----:|:---------------:|:---------:|:------:|:--------:|:--------:|:------------------:|| No log | 0 | 0 | 5.6298 | 0.0010 | 0.1667 | 0.0020 | 0.0059 | 0 || 0.3853 | 1.4493 | 1000 | 0.3886 | 0.4945 | 0.3110 | 0.3354 | 0.6037 | 0.5761 || 0.3791 | 2.8986 | 2000 | 0.3729 | 0.5041 | 0.3090 | 0.3395 | 0.6208 | 0.5716 || 0.3722 | 4.3478 | 3000 | 0.3720 | 0.5261 | 0.3116 | 0.3440 | 0.6189 | 0.5673 || 0.3751 | 5.7971 | 4000 | 0.3704 | 0.5247 | 0.3204 | 0.3565 | 0.6199 | 0.5766 || 0.3651 | 7.2464 | 5000 | 0.3718 | 0.5113 | 0.3352 | 0.3678 | 0.6310 | 0.5161 || 0.3695 | 8.6957 | 6000 | 0.3649 | 0.5055 | 0.3253 | 0.3607 | 0.6249 | 0.5632 || 0.361 | 10.1449 | 7000 | 0.3647 | 0.5042 | 0.3236 | 0.3571 | 0.6354 | 0.5410 || 0.3666 | 11.5942 | 8000 | 0.3764 | 0.5290 | 0.3371 | 0.3752 | 0.6146 | 0.5941 || 0.3563 | 13.0435 | 9000 | 0.3617 | 0.5179 | 0.3356 | 0.3743 | 0.6303 | 0.5674 || 0.3735 | 14.4928 | 10000 | 0.3663 | 0.4998 | 0.3423 | 0.3760 | 0.6340 | 0.5320 || 0.349 | 15.9420 | 11000 | 0.3616 | 0.5063 | 0.3306 | 0.3681 | 0.6273 | 0.5696 || 0.3679 | 17.3913 | 12000 | 0.3632 | 0.5078 | 0.3396 | 0.3786 | 0.6252 | 0.5762 || 0.3622 | 18.8406 | 13000 | 0.3612 | 0.5135 | 0.3322 | 0.3711 | 0.6277 | 0.5704 |### Framework versions- Transformers 4.43.4- Pytorch 2.4.0+cu121- Datasets 2.21.0- Tokenizers 0.19.110 unmodified lines1112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767710 unmodified lines88899091929394959697989910010110210310410510610 unmodified linesresults: []---# stack-edu-classifier-javascriptThis is a classifier for scoring the educational value of code files in The Stack v2 dataset, it is a finetuned version of [bigcode/starencoder](https://huggingface.co/bigcode/starencoder) with a classification head on code files annotated by Llama3.1-70B-Instruct. We use this classifier for building Stack-Edu dataset used for training SmolLM2, see [paper](https://arxiv.org/pdf/2502.02737). Each classifier is trained on one programming language.### How to use in transformersTo load the classifier, use the following code:```pythonfrom transformers import AutoTokenizer, AutoModelForSequenceClassificationtokenizer = AutoTokenizer.from_pretrained(REPO_NAME)model = AutoModelForSequenceClassification.from_pretrained(REPO_NAME)text = "This is a test sentence."inputs = tokenizer(text, return_tensors="pt", padding="longest", truncation=True)outputs = model(**inputs)logits = outputs.logits.squeeze(-1).float().detach().numpy()score = logits.item()result = {"text": text,"score": score,"int_score": int(round(max(0, min(score, 5)))),}print(result)# {'text': 'This is a test sentence.', 'score': 0.07964489609003067, 'int_score': 0}```## Intended uses & limitationsWhile the classifier performs well in distinguishing high-quality code in its target language (C++ in this case), there are some limitations:- Scope: The model's performance might change for other datasets, in particular for out of distribution samples. The classifier's context is 1024 tokens, which might not be sufficient to assess the quality of some long code files.- Bias: The model's performance is dependent on the quality and representativeness of the training data and the LLM used for the annotation. Biases in both can affect the classifier's judgments. It might overfit to thoroughly commented code.- Context: The classifier evaluates individual code files without considering broader context, which might impact its effectiveness in certain scenarios.The training and inference code is available on GitHubhttps://github.com/huggingface/cosmopedia/tree/main/classification## Training procedureThe classifier was trained on 500,000 pairs of code files and their scores from 0 to 5, generated by Llama3.1. The samples were annotated based on their educational quality with 1 being not educational and 5 being highly educational and relevant for teaching programming. You can find the prompt used for building the annotations in the appendix of [SmolLM2 paper](https://arxiv.org/pdf/2502.02737).We added a classification head with a single regression output to StarEncoder and trained the model for 20 epochs with a learning rate of 3e-4. During training, the embedding and encoder layers were frozen to focus on the classification head.It achieves the following results on the evaluation set:- Loss: 0.3612- Precision: 0.5135- Recall: 0.3322- F1 Macro: 0.3711- Accuracy: 0.6277- F1 Binary Minimum3: 0.5704While the macro F1 scores across the 1-5 rating scale are relatively low due to the model's difficulty in distinguishing between higher-rated samples, the classifier performs well for our primary filtering task. When converting to binary classification, using a threshold of 2 achieves the F1 scores ranges between 0.8 and 0.9 for most Stack-Edu classifiers, whereas a threshold of 3 yields F1 scores between 0.55 and 0.70. With the Highest being Python, C, Rust and the lowest being TypeScript and PHP.<div style="display: flex; justify-content: center; gap: 20px;"><img src="https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/z0lCnH2nqYMu09JsxPvFb.png" width="600"><img src="https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/W6BQO6Rkafpj-96fWdCOv.png" width="600"></div>We validated these classifiers by filtering Stack v2 data and testing on an intermediate SmolLM2 checkpoint. Filtering with a threshold of 3 improved performance across most languages while maintaining adequate data volume, though Java showed better results with a threshold of 2.### Training hyperparametersThe following hyperparameters were used during training:10 unmodified lines- lr_scheduler_warmup_steps: 200- num_epochs: 20## License[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)## Citation```bash@misc{allal2025smollm2smolgoesbig,title={SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model},author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Guilherme Penedo and Lewis Tunstall and Andrés Marafioti and Hynek Kydlíček and Agustín Piqueres Lajarín and Vaibhav Srivastav and Joshua Lochner and Caleb Fahlgren and Xuan-Son Nguyen and Clémentine Fourrier and Ben Burtenshaw and Hugo Larcher and Haojun Zhao and Cyril Zakka and Mathieu Morlon and Colin Raffel and Leandro von Werra and Thomas Wolf},year={2025},eprint={2502.02737},archivePrefix={arXiv},primaryClass={cs.CL},url={https://arxiv.org/abs/2502.02737},}```
README.md+65-42