unslothai / unsloth

Finetune Llama 3.2, Mistral, Phi, Qwen 2.5 & Gemma LLMs 2-5x faster with 80% less memory
https://unsloth.ai
Apache License 2.0
18.14k stars 1.27k forks source link

Error in introducing task_type as TOKEN_CLS #1085

Open yaswanthan opened 1 month ago

yaswanthan commented 1 month ago

Issue: TypeError when initializing task_type using unsloth pipeline in SFT

I am trying to fine-tune the Mistral 7B quantized model and have introduced task_type as token_cls. However, I am encountering the following error:

              **TypeError: dict() got multiple values for keyword argument 'task_type'.**

Here’s the code snippet I’m using:


model = FastLanguageModel.get_peft_model(
    model,
    r = 16,  # Choose any number > 0! Suggested: 8, 16, 32, 64, 128
    target_modules = ["q_proj", "k_proj", "v_proj", "o_proj", 
                      "gate_proj", "up_proj", "down_proj"],
    lora_alpha = 16,
    lora_dropout = 0,  # Supports any, but = 0 is optimized
    bias = "none",
    task_type = 'TOKEN_CLS',  # Supports any, but = "none" is optimized
    use_gradient_checkpointing = "unsloth",  # True or "unsloth" for long contexts
    random_state = 3407,
    loftq_config = None,  # And LoftQ
)

**Question:**
Can the task_type be initialized using the unsloth pipeline in SFT?
Could someone help identify where changes are needed to fix this issue?
Thanks in advance!
danielhanchen commented 1 month ago

Oh wait I don't think that's supported! If you're trying to predict 1 token as an output, just do normal finetuning, except set labels as the target you want