Код: Выделить всё
#Load of the model
model_checkpoint = 'microsoft/deberta-v3-large'
# model_checkpoint = 'roberta-base' # you can alternatively use roberta-base but this model is bigger thus training will take longer
# Define label maps specific to your task
id2label = {0: "Human", 1: "AI"}
label2id = {"Human": 0, "AI": 1}
# Generate classification model from model_checkpoint with the defined labels
model = AutoModelForSequenceClassification.from_pretrained(
model_checkpoint, num_labels=2, id2label=id2label, label2id=label2id)
peft_config = LoraConfig(task_type="SEQ_CLS",
r=1,
lora_alpha=16,
lora_dropout=0.2)
model = get_peft_model(model, peft_config)
Когда я закончу, я хочу сохранить модель для экспорта его на другую машину, с
Код: Выделить всё
model_path = "./deberta-v3-large-5"
model.save_pretrained(model_path)
Код: Выделить всё
reloaded_model = AutoModelForSequenceClassification.from_pretrained(
model_path, num_labels=2, id2label=id2label, label2id=label2id)
Если я запускаю тесты на своей reloaded_model, я получаю гораздо худшую точность, чем на исходная модель, которая была обучена
Я тоже пробовал, но безуспешно:
Код: Выделить всё
# Save the model and the tokenizer
model_path = "./deberta-v3-large-4"
trainer.save_model(model_path)
tokenizer.save_pretrained(model_path, set_lower_case=False)
from transformers import AutoModelForSequenceClassification, AutoTokenizer
# Path where the model and tokenizer were saved
model_path = "./deberta-v3-large-4"
# Define label maps specific to your task
id2label = {0: "Human", 1: "AI"}
label2id = {"Human": 0, "AI": 1}
# Generate classification model from model_checkpoint with the defined labels
model_regenerate = AutoModelForSequenceClassification.from_pretrained(
model_path, num_labels=2, id2label=id2label, label2id=label2id)
tokenizer_reloaded = AutoTokenizer.from_pretrained(model_path)
peft_config = LoraConfig(task_type="SEQ_CLS",
r=1,
lora_alpha=16,
lora_dropout=0.2)
model_full_regenerate = get_peft_model(model_regenerate, peft_config)
model_full_regenerate.print_trainable_parameters()
Код: Выделить всё
Some weights of DebertaV2ForSequenceClassification were not initialized from the model checkpoint at microsoft/deberta-v3-large and are newly initialized: ['classifier.bias', 'classifier.weight', 'pooler.dense.bias', 'pooler.dense.weight']
Подробнее здесь: https://stackoverflow.com/questions/783 ... that-was-s