Skip to content

CLUE阅读理解

zhezhaoa edited this page Aug 24, 2023 · 3 revisions

以下是CLUE阅读理解解决方案的简要介绍。

CMRC2018

利用cluecorpussmall_roberta_wwm_large_seq512_model.bin在CMRC2018数据集上做微调和预测示例:

python3 finetune/run_cmrc.py --pretrained_model_path models/cluecorpussmall_roberta_wwm_large_seq512_model.bin \
                             --vocab_path models/google_zh_vocab.txt \
                             --config_path models/bert/large_config.json \
                             --train_path datasets/cmrc2018/train.json \
                             --dev_path datasets/cmrc2018/dev.json \
                             --output_model_path models/cmrc_model.bin \
                             --epochs_num 2 --batch_size 8 --seq_length 512

python3 inference/run_cmrc_infer.py --load_model_path models/cmrc_model.bin \
                                    --vocab_path models/google_zh_vocab.txt \
                                    --config_path models/bert/large_config.json \
                                    --test_path datasets/cmrc2018/test.json \
                                    --prediction_path datasets/cmrc2018/prediction.json \
                                    --seq_length 512

ChID

利用cluecorpussmall_roberta_wwm_large_seq512_model.bin在ChID数据集上做微调和预测示例:

python3 finetune/run_chid.py --pretrained_model_path models/cluecorpussmall_roberta_wwm_large_seq512_model.bin \
                             --vocab_path models/google_zh_vocab.txt \
                             --config_path models/bert/large_config.json \
                             --train_path datasets/chid/train.json --train_answer_path datasets/chid/train_answer.json \
                             --dev_path datasets/chid/dev.json --dev_answer_path datasets/chid/dev_answer.json \
                             --output_model_path models/multichoice_model.bin \
                             --report_steps 1000 \
                             --epochs_num 3 --batch_size 16 --seq_length 64 --max_choices_num 10

python3 inference/run_chid_infer.py --load_model_path models/multichoice_model.bin \
                                    --vocab_path models/google_zh_vocab.txt \
                                    --config_path models/bert/large_config.json \
                                    --test_path datasets/chid/test.json \
                                    --prediction_path datasets/chid/prediction.json \
                                    --seq_length 64 --max_choices_num 10

注意到需要在推理阶段使用函数 postprocess_chid_predictions 对预测结果进行后处理。这能显著提升模型在ChID数据集上的表现。

C3

利用cluecorpussmall_roberta_wwm_large_seq512_model.bin在C3数据集上做微调和预测示例:

python3 finetune/run_c3.py --pretrained_model_path models/cluecorpussmall_roberta_wwm_large_seq512_model.bin \
                           --vocab_path models/google_zh_vocab.txt \
                           --config_path models/bert/large_config.json \
                           --train_path datasets/c3/train.json --dev_path datasets/c3/dev.json \
                           --output_model_path models/multichoice_model.bin \
                           --learning_rate 1e-5 --epochs_num 5 --batch_size 8 --seq_length 512 --max_choices_num 4

python3 inference/run_c3_infer.py --load_model_path models/multichoice_model.bin \
                                  --vocab_path models/google_zh_vocab.txt \
                                  --config_path models/bert/large_config.json \
                                  --test_path datasets/c3/test.json \
                                  --prediction_path datasets/c3/prediction.json \
                                  --seq_length 512 --max_choices_num 4
Clone this wiki locally