CoolFace
Modelpublic

yugh/music_ent_classification

sourceHugging Faceapache-2.0updated 8mo agoView on Hugging Face
0likes11downloads
Model Card

<!-- This model card has been generated automatically according to the information the Trainer had access to. You should probably proofread and complete it, then remove this comment. -->

musicentclassification

This model is a fine-tuned version of hfl/chinese-roberta-wwm-ext on an unknown dataset. It achieves the following results on the evaluation set:

  • Loss: 0.1230
  • Accuracy: 0.9662

Model description

More information needed

Intended uses & limitations

More information needed

Training and evaluation data

More information needed

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 2e-05
  • trainbatchsize: 32
  • evalbatchsize: 8
  • seed: 42
  • distributed_type: multi-GPU
  • num_devices: 4
  • totaltrainbatch_size: 128
  • totalevalbatch_size: 32
  • optimizer: Use adamwtorch with betas=(0.9,0.999) and epsilon=1e-08 and optimizerargs=No additional optimizer arguments
  • lrschedulertype: linear
  • num_epochs: 5.0
  • mixedprecisiontraining: Native AMP

Training results

Training LossEpochStepValidation LossAccuracy
0.44081.0540.17630.9459
0.14072.01080.12210.9628
0.07623.01620.11230.9640
0.05634.02160.12260.9718
0.04235.02700.12300.9662

Framework versions

  • Transformers 4.57.5
  • Pytorch 2.6.0+cu124
  • Datasets 2.19.0
  • Tokenizers 0.22.2

训练

export WANDB_MODE=disabled # 禁用交互式登录
export CUDA_VISIBLE_DEVICES=0,1,2,3 # 确保识别 4 张 V100
# 变量定义
model="hfl/chinese-roberta-wwm-ext"
transformers_root="transformers"

output_dir="./models/music_ent_classification"
mkdir ${output_dir} -p

# 使用 torchrun 启动
torchrun --nproc_per_node=4 \
    ${transformers_root}/examples/pytorch/text-classification/run_classification.py \
    --model_name_or_path ${model} \
    --train_file "./data/*.train.json" \
    --validation_file "./data/*.test.json" \
    --trust_remote_code True \
    --do_train \
    --do_eval \
    --shuffle_train_dataset \
    --metric_name accuracy \
    --text_column_name sentence1 \
    --label_column_name label \
    --max_seq_length 256 \
    --per_device_train_batch_size 32 \
    --learning_rate 2e-5 \
    --num_train_epochs 5 \
    --logging_steps 50 \
    --save_strategy epoch \
    --eval_strategy epoch \
    --fp16 True \
    --output_dir ${output_dir} \
    --overwrite_output_dir 

推理

# 启动分布式推理
torchrun --nproc_per_node=$(echo $CUDA_DEVICES | tr ',' '\n' | wc -l) \
    transformers/examples/pytorch/text-classification/run_classification.py \
    --model_name_or_path "${MODEL_PATH}" \
    --train_file "${TRAIN_DATA}" \
    --validation_file "${TRAIN_DATA}" \
    --test_file "${INPUT_FILE}" \
    --text_column_name "sentence1" \
    --label_column_name "label" \
    --do_predict \
    --max_seq_length 128 \
    --per_device_eval_batch_size 256 \
    --output_dir "${OUTPUT_DIR}" \
    --fp16 True \
    --trust_remote_code True \
    --overwrite_output_dir

if [ $? -eq 0 ]; then
    echo "✅ [Infer] 推理完成。"
else
    echo "❌ [Infer] 推理失败。"
    exit 1
fi