stanfordnlp / pyreft

ReFT: Representation Finetuning for Language Models
https://arxiv.org/abs/2404.03592
Apache License 2.0
947 stars 77 forks source link

[P1] Transitioning from peft to pyreft for Classification Approach #92

Open SaBay89 opened 1 month ago

SaBay89 commented 1 month ago

I'm encountering problems when training a classification model. While the peft library works without errors and initiates training, using pyreft instead results in the following error:

**ValueError: You should supply an encoding or a list of encodings to this method that includes input_ids, but you provided ['labels']

Features of the input for training: ['input_ids', 'attention_mask', 'labels']

--> trainable params: 78,794,752 || all params: 2,585,315,328 || trainable%: 3.0478_

This works without any errors and the training starts.

The same with pyreft

--> trainable intervention params: 16,388 || trainable model params: 0 --> model params: 2,506,520,576 || trainable%: 0.0006538147006218711

The error arises also when I use the pyreft.ReftTrainerForSequenceClassification class from the pyreft library instead of the standard Trainer class. While the peft library works seamlessly with the Trainer class, it seems that pyreft requires a different approach for data preparation.

I apologize for any misrepresentation that may arise from directly comparing peft to pyreft. My intention is not to diminish the capabilities of pyreft but rather to highlight the specific challenges I've encountered while transitioning from a familiar tool to a new one.

frankaging commented 1 month ago

@SaBay89 hi, thanks for raising the question.

please take a look at our GLUE experiment setup for sequence classification tasks: https://github.com/stanfordnlp/pyreft/blob/main/examples/loreft/train.py#L363

what are the fields for your training dataset? tokenized_dataset_train? does it contain all the needed fields?

xinlanz commented 3 weeks ago

May I ask if you have solved this problem, I had the same problem