Skip to content

unexpected keyword argument tokenizer [FIXED]  #1285

Closed

Description

@avemio-digital

I used orpo colab example for mistral model and I am getting this error. I am using below configs

from trl import ORPOConfig, ORPOTrainer
from unsloth import is_bfloat16_supported

orpo_trainer = ORPOTrainer(
model = model,
train_dataset = dataset,
tokenizer = tokenizer,
args = ORPOConfig(
max_length = max_seq_length,
max_prompt_length = max_seq_length//2,
max_completion_length = max_seq_length//2,
per_device_train_batch_size = 2,
gradient_accumulation_steps = 4,
beta = 0.1,
logging_steps = 1,
optim = "adamw_8bit",
lr_scheduler_type = "linear",
max_steps = 1500, # Change to num_train_epochs = 1 for full training runs
fp16 = not is_bfloat16_supported(),
bf16 = is_bfloat16_supported(),
output_dir = "outputs",
report_to = "none", # Use this for WandB etc
),
)

Activity

  1. dame-cell commented on Nov 13, 2024

    @dame-cell
    Contributor

    So unsloth uses the newest version of trl always and just recently trl just updated and remove the tokenizer parameter to processing_class mentioned here 2348
    you can simply do this

    - trainer = DPOTrainer(model, args=training_args, train_dataset=dataset, tokenizer=tokenizer)
    + trainer = DPOTrainer(model, args=training_args, train_dataset=dataset, processing_class=tokenizer)
    
  2. Erland366 commented on Nov 13, 2024

    @Erland366
    Collaborator

    Unsloth will make backward compability I think

  3. changed the title [-]ORPOTrainer.__init__() got an unexpected keyword argument 'tokenizer'[/-] [+][FIXED] `unexpected keyword argument tokenizer`[/+] on Nov 14, 2024
  4. added
    fixed - pending confirmation
    on Nov 14, 2024
  5. danielhanchen commented on Nov 14, 2024

    @danielhanchen
    Member

    Just fixed @avemio-digital @dame-cell ! Please update Unsloth on local machines via pip install --upgrade --no-cache-dir --no-deps unsloth. For Colab, Kaggle, just refresh!

  6. changed the title [-][FIXED] `unexpected keyword argument tokenizer`[/-] [+]`unexpected keyword argument tokenizer` [FIXED] [/+] on Nov 14, 2024
  7. qgallouedec commented on Nov 14, 2024

    @qgallouedec
    Contributor

    This has been fixed in trl v0.12.1, make sure to run

    pip install --upgrade trl
    

    please also note that tokenizer is deprecated, so you should prefer processing_class, as mentioned by @dame-cell in #1285 (comment)

  8. unpinned this issue on Dec 4, 2024
  9. rolandtannous commented on Jun 29, 2025

    @rolandtannous
    Contributor

    This should now be resolved in the latest unsloth.
    Please make sure to update your environment to the latest version

    pip install --upgrade unsloth-zoo
    pip install --upgrade unsloth
    

    Will close this for now.
    Feel free to comment back with details if you are still experiencing the same issue.
    Thank you for using Unsloth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed - pending confirmation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions