Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 12 #32

Closed
ritesh2014 opened this issue Jan 27, 2025 · 4 comments
Closed

Chapter 12 #32

ritesh2014 opened this issue Jan 27, 2025 · 4 comments

Comments

@ritesh2014
Copy link

Below Code:

trainer = SFTTrainer(
model=model,
train_dataset=dataset,
dataset_text_field="text",
tokenizer=tokenizer,
args=training_arguments,
max_seq_length=512,

# Leave this out for regular SFT
peft_config=peft_config,

)

Error:
TypeError: SFTTrainer.init() got an unexpected keyword argument 'dataset_text_field'

Tried to resolve using Gemini, but the solutions kept throwing new errors and the code got messed up.
Has anyone resolved this?

@MaartenGr
Copy link
Contributor

Where are you using the above code, in Colab? If so, can you use the versions of transformers/trl as shown in the requirements.txt?

@ritesh2014
Copy link
Author

Using Colab.

So changed -
!pip install -q accelerate peft bitsandbytes transformers trl sentencepiece

To-
!pip install -q accelerate==0.31.0 peft==0.11.1 bitsandbytes==0.43.1 transformers==4.41.2 trl==0.9.4 sentencepiece==0.2.0

Had to provide versions to all the libs as additional errors were cropping up.
Now it works. When you can, pls change the notebook in Github to prevent this occurence for others.

MaartenGr added a commit that referenced this issue Feb 5, 2025
@MaartenGr
Copy link
Contributor

@ritesh2014 Thanks for testing the updated requirements! I finally had some time to update this and it should work now. Also, the reason why this took a bit longer is a nice one (cool update in a couple of hours 😉).

@amina-mardiyyah
Copy link

amina-mardiyyah commented Feb 7, 2025

For future reference or anyone who bumps into this error on Colab, you could also replace transformers TrainingArguments with SFTConfig from SFT instead. Then define parameters as below:

training_arguments = SFTConfig(
    output_dir=output_dir,
    per_device_train_batch_size=2,
    gradient_accumulation_steps=4,
    optim="paged_adamw_32bit",
    learning_rate=2e-4,
    lr_scheduler_type="cosine",
    num_train_epochs=1,
    logging_steps=10,
    max_seq_length = 512,
    fp16=True,
    gradient_checkpointing=True,
    dataset_text_field="text", 
)

Then:


trainer = SFTTrainer(
     model=model,
     train_dataset=dataset,
     tokenizer=tokenizer,
     args=training_arguments,
 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants