Skip to content

sequence classification inference #4093

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

Open
Lettie-LIU opened this issue May 6, 2025 · 1 comment
Open

sequence classification inference #4093

Lettie-LIU opened this issue May 6, 2025 · 1 comment

Comments

@Lettie-LIU
Copy link

Lettie-LIU commented May 6, 2025

I fine-tuned a multi-label classification model using the following script:
swift sft \ --model Qwen/Qwen2.5-0.5B \ --train_type lora \ --dataset 'training.json' \ --torch_dtype bfloat16 \ --num_train_epochs 1 \ --per_device_train_batch_size 1 \ --per_device_eval_batch_size 1 \ --learning_rate 1e-4 \ --lora_rank 8 \ --lora_alpha 32 \ --target_modules all-linear \ --gradient_accumulation_steps 16 \ --eval_steps 50 \ --save_steps 50 \ --save_total_limit 2 \ --logging_steps 5 \ --max_length 2048 \ --output_dir output \ --warmup_ratio 0.05 \ --dataloader_num_workers 4 \ --num_labels 8 \ --task_type seq_cls \ --use_chat_template false

Once the model was fine-tuned, I ran inference on the validation set using the following script:
swift infer \ --adapters checkpoint-200 \ #fine-tuned ckpt --val_dataset validation.json \ --infer_backend pt \ --temperature 0 \ --max_new_tokens 4096 \ --logprobs true \ --load_data_args true \ --stream true

Training and Validation Dataset Format:
Both the training and validation datasets are structured as follows:
[ {"messages": [{"role": "user", "content": "<video>question?"}], "label": [1, 6], "videos": ["video1.mp4"]}, {"messages": [{"role": "user", "content": "<video>question?"}], "label": [1, 5], "videos": ["video2.mp4"]}, {"messages": [{"role": "user", "content": "<video>question"}], "label": [1, 3, 4], "videos": ["videos3.mp4"]},........]

Problem:
After running the inference, the model does not produce the expected classification labels. Instead, it outputs the same log_probs for all videos and repeats the label input from validation.json without providing proper label predictions.
{"response": [], "labels": [], "logprobs": {"content": [{"index": [], "logprobs": [], "top_logprobs": [{"index": 6, "logprob": -1.1640625}, {"index": 7, "logprob": -1.171875}, {"index": 4, "logprob": -1.1796875}, {"index": 2, "logprob": -1.203125}, {"index": 5, "logprob": -1.296875}, {"index": 3, "logprob": -1.3515625}, {"index": 0, "logprob": -1.3515625}, {"index": 1, "logprob": -1.375}]}]}, "messages": [{"role": "user", "content": "<video>question?"}, {"role": "assistant", "content": []}], "videos": ["val01.mp4"]} {"response": [], "labels": [], "logprobs": {"content": [{"index": [], "logprobs": [], "top_logprobs": [{"index": 6, "logprob": -1.1640625}, {"index": 7, "logprob": -1.171875}, {"index": 4, "logprob": -1.1796875}, {"index": 2, "logprob": -1.203125}, {"index": 5, "logprob": -1.296875}, {"index": 3, "logprob": -1.3515625}, {"index": 0, "logprob": -1.3515625}, {"index": 1, "logprob": -1.375}]}]}, "messages": [{"role": "user", "content": "<video>question?"}, {"role": "assistant", "content": []}], "videos": ["val02.mp4"].....}
I am wondering if there might be any issues with my inference script or the data format. Thank you.

@Jintao-Huang
Copy link
Collaborator

Jintao-Huang commented May 6, 2025

Qwen/Qwen2.5-0.5B

Does not support multimodal input.

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

2 participants