Сегментированная модель Falcon-7b — RuntimeError: размер представления несовместим с размером и шагом входного тензора

Недавно я настраиваю сегментированную модель Falcon-7b на основе набора данных pubmedQA, предоставленного Hugging face. Для этого я использую настройку префикса. Однако на последнем этапе, когда я вызываю тренера, выскакивает следующая ошибка

      You're using a PreTrainedTokenizerFast tokenizer. Please note that with a fast tokenizer, using the `__call__` method is faster than using a method to encode the text followed by a call to the `pad` method to get a padded encoding.
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-17-3435b262f1ae> in <cell line: 1>()
----> 1 trainer.train()

16 frames
~/.cache/huggingface/modules/transformers_modules/vilsonrodrigues/falcon-7b-sharded/5206b4cb8d6be73aa3d0d52360009437d196f28f/modeling_falcon.py in <genexpr>(.0)
    625         return tuple(
    626             (
--> 627                 layer_past[0].view(batch_size_times_num_heads, kv_length, head_dim),
    628                 layer_past[1].view(batch_size_times_num_heads, kv_length, head_dim),
    629             )

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

Это мой объект тренера:

      from trl import SFTTrainer

trainer = SFTTrainer(
    model=model,
    args=training_args,
    peft_config=peft_config,
    tokenizer=tokenizer,
    dataset_text_field="text",
    train_dataset=dataset_train,
    eval_dataset=dataset_val,
)

Вот мои аргументы в пользу обучения:

      from transformers import TrainingArguments

#Arguments needed for training process
output_dir = "falcon-7b-sharded"
per_device_train_batch_size = 5
gradient_accumulation_steps = 4
device = "cuda"
num_epochs = 10
#Torch adamw optimization algorithm is used in QLoRA
optim = "adamw_torch"
save_steps = 10
logging_steps = 10
learning_rate = 5e-5
max_grad_norm = 0.3
max_steps = 200
warmup_ratio = 0
lr_scheduler_type = "linear"


training_args = TrainingArguments(
    output_dir=output_dir,
    per_device_train_batch_size=per_device_train_batch_size,
    num_train_epochs=num_epochs,
    gradient_accumulation_steps=gradient_accumulation_steps,
    optim=optim,
    save_steps=save_steps,
    logging_steps=logging_steps,
    learning_rate=learning_rate,
    fp16=True,
    max_grad_norm=max_grad_norm,
    max_steps=max_steps,
    warmup_ratio=warmup_ratio,
    group_by_length=True,
    report_to=None,
    lr_scheduler_type=lr_scheduler_type

)

model = model.to(device)

Насколько я понимаю, эта ошибка кроется в скрытом коде предварительно обученной модели, к которому у меня нет доступа для изменения. Есть ли у кого-нибудь решения для этого?

Спасибо

0 ответов

Другие вопросы по тегам