/ Модель

Характеристики

Контекст
512 токенов
Параметры
137 млн
Лицензия
Apache 2.0
Архитектура
bert · dense
Базовая модель
snowflake-arctic-embed-m
Опубликована
28 июн 2024

python-edu-scorer

Классификация текстаТекст → label3 профессии

BERT-классификатор оценивает образовательную ценность отдельных Python-файлов для начинающих.

141скачиваний за 30 дней31лайквеса обновлены16 июл 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Python-Edu Scorer — модель классификации кода, разработанная HuggingFaceTB и дообученная на базе Snowflake/snowflake-arctic-embed-m. Она оценивает образовательную ценность Python-файлов; метки для обучающего набора были созданы Llama 3. Модель использовалась при создании набора данных Python-Edu.

Это BERT-классификатор последовательностей размером 136,7 млн параметров с контекстом до 512 токенов. Он принимает текст отдельного файла и выдаёт классификационную оценку. Репозиторий содержит веса в формате safetensors. Лицензия — Apache-2.0.

Модель предназначена для отбора Python-кода, полезного начинающим учащимся. Её результаты могут ухудшаться на данных, отличающихся от обучающих, и на специализированном или продвинутом учебном материале. На оценки могут влиять смещения обучающих данных и разметки, а также обилие комментариев в коде; классификатор анализирует файлы по отдельности, без окружающего контекста.

Сценарии применения

  • отбор Python-файлов для учебного набора данных
  • ранжирование примеров кода по полезности для начинающих
  • фильтрация Python-кода для обучающих материалов

Ограничения

Качество может снижаться на данных, отличающихся от обучающих, и на продвинутом или специализированном коде; классификатор оценивает файлы без окружающего контекста и может зависеть от смещений разметки или обилия комментариев.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Python-Edu Scorer

This model is a fine-tuned version of Snowflake/snowflake-arctic-embed-m on a dataset of Python files labeled by Llama3 for educational value. We used this classifier to build the Python-Edu dataset.

How to use in transformers

To load the Python-Edu classifier, use the following code:

from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/python-edu-scorer")
model = AutoModelForSequenceClassification.from_pretrained("HuggingFaceTB/python-edu-scorer")

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 & limitations

While the Python-Edu classifier performs well in distinguishing high-quality python code, there are some limitations:

  • Scope: The model's performance might change for other datasets, in particular for out of distribution samples. It is also focused on educational content relevant to beginners and may not perform as well on content intended for higher education or specialized domains.
  • 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 GitHub https://github.com/huggingface/cosmopedia/tree/main/classification

Training procedure

The classifier was trained on 450,000 pairs of python code files and their scores from 1 to 5, generated by Llama3. The samples were annotated based on their educational quality with 1 being not educational and 5 being highly educational.

We added a classification head with a single regression output to Snowflake-arctic-embed 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.

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 0.0003
  • train_batch_size: 256
  • eval_batch_size: 128
  • seed: 0
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • lr_scheduler_type: linear
  • num_epochs: 20

Training results

              precision    recall  f1-score   support

           1       0.84      0.46      0.59      8364
           2       0.61      0.76      0.68     19605
           3       0.60      0.62      0.61     16187
           4       0.72      0.50      0.59      4872
           5       0.38      0.08      0.13       118

    accuracy                           0.64     49146
   macro avg       0.63      0.48      0.52     49146
weighted avg       0.66      0.64      0.63     49146

Framework versions

  • Transformers 4.40.1
  • Pytorch 2.2.0+cu121
  • Datasets 2.17.1
  • Tokenizers 0.19.1

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · text-classification

Можно запустить

Подбираем GPU…

Класс архитектуры
BertForSequenceClassification
Ревизия весов
76b46de

0 моделей