transformers icon indicating copy to clipboard operation
transformers copied to clipboard

why the acc of chinese model(bert) is just 0.438

Open zsk423200 opened this issue 7 years ago • 4 comments

dataset: XNLI-1.0 i run the dataset of xnli-1.0, but the result is acc = 0.43855421686746987, and i run on google bert in tf, the result is eval_accuracy = 0.7674699. i use the same epochs and lr, i really don't know why.

i add the dataprocess of xnli ,the same with the version of tf bert:

class XnliProcessor(DataProcessor):
  """Processor for the XNLI data set."""

  def __init__(self):
    self.language = "zh"

  def get_train_examples(self, data_dir):
    """See base class."""
    lines = self._read_tsv(
        os.path.join(data_dir, "multinli",
                     "multinli.train.%s.tsv" % self.language))
    examples = []
    for (i, line) in enumerate(lines):
      if i == 0:
        continue
      guid = "train-%d" % (i)
      text_a = line[0]
      text_b = line[1]
      label = line[2]
      if label == "contradictory":
        label = "contradiction"
      examples.append(
          InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label))
    return examples

  def get_dev_examples(self, data_dir):
    """See base class."""
    lines = self._read_tsv(os.path.join(data_dir, "xnli.dev.tsv"))
    examples = []
    for (i, line) in enumerate(lines):
      if i == 0:
        continue
      guid = "dev-%d" % (i)
      language = line[0]
      if language != self.language:
        continue
      text_a = line[6]
      text_b = line[7]
      label = line[1]
      examples.append(
          InputExample(guid=guid, text_a=text_a, text_b=text_b, label=label))
    return examples

  def get_labels(self):
    """See base class."""
    return ["contradiction", "entailment", "neutral"]

and my pytorch command is :

python run_glue.py --model_type bert --model_name_or_path bert-base-chinese --task_name XNLI --do_train --do_eval --do_lower_case --data_dir $XNLI_DIR --max_seq_length 128 --per_gpu_eval_batch_size=8 --per_gpu_train_batch_size=8 --learning_rate 5e-5 --num_train_epochs 2.0 --output_dir /tmp/MRPC4/ --overwrite_output_dir --save_steps=1000

and my tf common is:

python run_classifier.py   --task_name=XNLI   --do_train=true   --do_eval=true   --data_dir=$XNLI_DIR   --vocab_file=$BERT_BASE_DIR/vocab.txt   --bert_config_file=$BERT_BASE_DIR/bert_config.json   --init_checkpoint=$BERT_BASE_DIR/bert_model.ckpt   --max_seq_length=128   --train_batch_size=32   --learning_rate=5e-5   --num_train_epochs=2.0   --output_dir=/tmp/xnli_output

zsk423200 avatar Jul 25 '19 11:07 zsk423200

i have the same issue as you. Do you have a good solution for it?

VolantBoy avatar Aug 15 '19 03:08 VolantBoy

I met the same problem in multi-labels classification task, have no idea about the problem!

weizaiff avatar Aug 17 '19 18:08 weizaiff

@zsk423200 Maybe you can try the "bert-base-multilingual-cased-pytorch_model" , it's performance seems better a lot than the pure Chinese ver in my task, just a temporal solu.

weizaiff avatar Aug 18 '19 05:08 weizaiff

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 17 '19 06:10 stale[bot]