lightseq icon indicating copy to clipboard operation
lightseq copied to clipboard

bart topk sample result is wrong

Open lonelydancer opened this issue 4 years ago • 7 comments

I'm using a bart model for text_generation.i modified https://github.com/lonelydancer/algorithm/blob/master/ls_bart2.py https://github.com/lonelydancer/algorithm/blob/master/hf_bart_export.py the generated text is wrong. image

lonelydancer avatar Jan 09 '22 08:01 lonelydancer

@Taka152 i tried, it doesn't work. My model is a generate model train by myself.

lonelydancer avatar Jan 10 '22 02:01 lonelydancer

Sampling doesn't have multiple outputs. You can feed a batch of the same inputs to get multiple outputs. For the wrong results, you can compile with debug info to find out. The example huggingface model works fine with topk sampling.

Taka152 avatar Jan 10 '22 08:01 Taka152

=

Sampling doesn't have multiple outputs. You can feed a batch of the same inputs to get multiple outputs. For the wrong results, you can compile with debug info to find out. The example huggingface model works fine with topk sampling.

  1. i can generate multi output use the method you mentioned.
  2. i change the task to a generate model, not the mask filled model in the demo.

lonelydancer avatar Jan 10 '22 08:01 lonelydancer

For your own model, I suggest compiling with debug info and checking each layer's output. If you can reproduce the wrong result on an open model, I can find out if it is a bug.

Taka152 avatar Jan 12 '22 02:01 Taka152

I think it may relate to tokenizer bos and eos config, you can check if they are passed to model_config correctly.

Taka152 avatar Jan 12 '22 07:01 Taka152

vocab.txt My vocab is above, and i set image the result is still wrong. 噢 噢 噢 , 昨 天 刚 刚 刚 刚 刚 忙 叨 忙 啦 唉 ! 唉 唉 呀 唉 唉 唉 啊 呀 呀 呀 哇 啊 哎 呀 啊 啦 哒 哎 呀 呀 呗 哟 i don't know the explain of the tgt_start_id, tgt_end_id ; i think i have only one vocabulary for the decoder. Is it ok i use a berttokenizer?

lonelydancer avatar Jan 13 '22 11:01 lonelydancer

For your own model, I suggest compiling with debug info and checking each layer's output. If you can reproduce the wrong result on an open model, I can find out if it is a bug.

i use the open model, facebook/bart-large-cnn, i think there is bug in export scripts? the code is here https://github.com/lonelydancer/algorithm/blob/master/hf_bart_export_en_summary.py https://github.com/lonelydancer/algorithm/blob/master/ls_bart_summary.py https://github.com/lonelydancer/algorithm/blob/master/test_bart.py huggingface in BartEncoder forward funtion image

image

image

lightseq image image

lonelydancer avatar Jan 20 '22 12:01 lonelydancer