BERT 在预测时跳过 test.tsv 的第一行

BERT skipping the 1st row of test.tsv when predicting

我是 运行 BERT-Base, Uncased pre-trained model on a news classification problem. Most of the core logic for data preparation was copied from here。不过,我 运行 它在不同的数据集上,因此已经进行了相关更改。我有 490 篇新闻文章,训练、验证、测试数据比率为 405 : 45 : 40。这些数据集存在于同一目录中的 train.tsvdev.tsvtest.tsv 文件中, 都没有 header。我用于 运行 分类器的命令是这样的:

python /Users/<username>/Documents/CodeBase/Projects/BERT/run_classifier.py \
--task_name=cola \
--do_train=true \
--do_eval=true \
--do_predict=true \
--data_dir=/Users/<username>/Desktop/NLP_Learning/Fraud\ detection/BERT \
--vocab_file=./vocab.txt \
--bert_config_file=./bert_config.json \
--init_checkpoint=./bert_model.ckpt \
--max_seq_length=128 \
--train_batch_size=32 \
--learning_rate=2e-5 \
--num_train_epochs=3.0 \
--output_dir=/Users/<username>/Desktop/NLP_Learning/Fraud\ detection/BERT_Model_Pretrained/output \
--do_lower_case=True

现在,即使训练和预测完成,问题是生成的 test_results.tsv 文件只包含 39 行,本应是 40 行。从外观上看,似乎是 [= 的第 0 行14=] 以某种方式被跳过。我在这里错过了什么?我检查了所有三个输入数据文件,它们都包含适当数量的记录。

是的,cola 任务的数据格式非常具体。它需要 3 个文件 train.tsvdev.tsvtest.tsv,分别用于 training-set、development/validation 集和测试集。

来到每个 TSV 文件中的 data-formats。 train.tsvdev.tsv 具有相同的格式:

id class_label segment text

并且 train.tsvdev.tsv 应该 而不是 有 header。

然而,来到test.tsv,下面是格式:

id text(请注意,您不应提供标签或细分列)。

更多重要test.tsv 应该有一个header.