Warning: "No label_names provided for PeftModel" persists despite dataset containing "labels" column
Author: Septemberlemon
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.49.0
- Platform: Windows-10-10.0.19045-SP0
- Python version: 3.11.3
- Huggingface_hub version: 0.29.3
- Safetensors version: 0.5.3
- Accelerate version: 1.5.2
- Accelerate config:    not found
- DeepSpeed version: not installed
- PyTorch version (GPU?): 2.5.1+cu124 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA GeForce RTX 3060

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [x] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [x] My own task or dataset (give details below)

### Reproduction

I'm learning to finetuning a llm, chatgpt write a demo for me, like
```python
from transformers import BitsAndBytesConfig, AutoModelForCausalLM, AutoTokenizer, TrainingArguments, Trainer
from peft import get_peft_model, LoraConfig
from datasets import load_dataset
import torch


# 加载预训练模型和分词器
model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
quant_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16)
model = AutoModelForCausalLM.from_pretrained(model_name,
                                             quantization_config=quant_config,
                                             device_map="auto",
                                             attn_implementation="flash_attention_2",)
tokenizer = AutoTokenizer.from_pretrained(model_name)
tokenizer.pad_token = tokenizer.eos_token  # 确保填充token已设置

# 配置 LoRA 参数
lora_config = LoraConfig(
    r=8,
    lora_alpha=32,
    target_modules=["q_proj", "v_proj"],
    lora_dropout=0.1,
    bias="none"
)
model = get_peft_model(model, lora_config)

# 加载数据集
dataset = load_dataset("json", data_files={
    "train": "train_data.jsonl",
    "validation": "val_data.jsonl"
})


def preprocess_function(examples):
    # 根据任务将指令、输入、输出拼接为一个完整的文本
    texts = [f"Instruction: {inst}\nInput: {inp}"
             for inst, inp in zip(examples["instruction"], examples["input"])]
    return tokenizer(texts,
                     text_target=examples["output"],
                     truncation=True, padding="max_length",
                     max_length=512,
                     )


# 应用预处理
tokenized_dataset = dataset.map(
    preprocess_function,
    batched=True,
    remove_columns=dataset["train"].column_names  # 自动移除原始列
)

# 调整训练参数
training_args = TrainingArguments(
    output_dir="./qlora_finetuned",
    per_device_train_batch_size=2,
    per_device_eval_batch_size=2,
    num_train_epochs=3,
    eval_strategy="steps",  # 替换过时的evaluation_strategy
    logging_steps=10,
    save_steps=50,
    fp16=True,
    remove_unused_columns=False,  # 重要：防止自动删除必要列
)

# 初始化Trainer
trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=tokenized_dataset["train"],
    eval_dataset=tokenized_dataset["validation"],
)

# 开始训练
trainer.train()
```
***
It really works, but I got a warning and after discussing with it we found it should be a bug, the warning is:
**No label_names provided for model class `PeftModel`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.**

### Expected behavior

without the warning

Comments:
cc @muellerzr @sunmarc for Trainer and @sayakpaul @benjaminbossan for PEFT!

Hmm, I'm not sure I understand the issue. The warning mentions that `label_names` was not provided and this is indeed the case, as the argument is not passed to `TrainingArguments`. As for the context why this is required, check my [earlier comment](https://github.com/huggingface/transformers/pull/32085#issuecomment-2263127696).

PS: @Rocketknight1 for PEFT issues, no need to ping Sayak, please ping `@githubnemo` and me instead.

Understood, and sorry!

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.