A Kaggle competition project for fine-tuning a quantized Qwen 2.5 model with LoRA adapters on a response-ranking classification task. The notebook trains a 3-way classifier to predict whether model_a, model_b, or tie is preferred based on a prompt and two model responses.
- Loads Kaggle-formatted competition datasets from mounted input paths.
- Builds a 3-class classification dataset from
winner_model_a,winner_model_b, andwinner_tielabels. - Applies response-swap augmentation to reduce positional bias.
- Converts prompt/response pairs into instruction-style training samples.
- Truncates long text using a head-and-tail strategy to preserve context.
- Fine-tunes
Qwen2.5-7B-Instructin 4-bit mode withbitsandbytesand LoRA. - Evaluates validation accuracy and produces a Kaggle
submission.csv.
llm-classification-finetuning-comp (9).ipynbβ main Kaggle notebook with end-to-end training and inference.infrencer-notebook.ipynbβ inference notebook for model evaluation and submission generation.README.mdβ project documentation.
This project is designed to work within Kaggle's GPU and offline package constraints while still enabling large-model fine-tuning. By combining 4-bit quantization with LoRA, the notebook keeps memory usage low and training feasible on smaller GPUs.
- Base model:
Qwen/Qwen2.5-7B-Instruct - Quantization: 4-bit (
bitsandbytes,nf4) - Fine-tuning: LoRA adapters
- Label classes:
A,B,C - Task type: sequence classification
Typical LoRA settings from the notebook:
- rank:
16 - alpha:
32 - dropout:
0.05 - target modules:
q_proj,k_proj,v_proj,o_proj
Training arguments in the notebook include:
- learning rate:
2e-4 - epochs:
1 - train batch size:
4 - eval batch size:
4 - gradient accumulation:
4 - optimizer:
paged_adamw_8bit - mixed precision:
fp16
The notebook expects Kaggle input mounts structured like:
/kaggle/input/competitions/llm-classification-finetuning/train.csv
/kaggle/input/competitions/llm-classification-finetuning/test.csv
/kaggle/input/models/qwen-lm/qwen2.5/transformers/7b-instruct/1
/kaggle/input/datasets/azizkarray/my-qwen-2-5-wheels/my_wheels
If your input paths differ, update the path variables in the first notebook cells before running.
The notebook installs and uses the following libraries:
transformerspeftbitsandbytestrlacceleratedatasetstorchpandasnumpyscikit-learn
- Open
llm-classification-finetuning-comp (9).ipynbin Kaggle or a compatible Jupyter environment. - Attach the Kaggle competition dataset and the local model/wheel datasets.
- Confirm the dataset and model input paths in the first cells.
- Execute the notebook from top to bottom.
- Use the inference notebook
infrencer-notebook.ipynbfor additional evaluation and submission generation.
Expected outputs from the notebook include:
- saved LoRA adapter checkpoint and tokenizer files
- a generated
submission.csv - model validation metrics logged in the notebook cells
- The project is notebook-first and optimized for Kaggle-style execution.
- The training pipeline is focused on memory-efficient fine-tuning of a large language model.
- The notebook includes dataset augmentation and prompt construction to improve classification robustness.