Loki Cheng | 10 Jul 2012 07:27
Picon

Can't evaluate the BLEU score for single sentence pairs

Hi, all
I can't evaluate the BLEU score for single sentence pairs with multi-bleu.perl. I don't know why? example just like below:

Original Chinese sentence: 安理會 還 請 建設 和平 委員會 向 安理會 提供 咨詢 意見 。
English translation result: 安理會 還 請 建設 和平 委員會 提供 咨詢 意見 的 委員會 。

error message: Use of uninitialized value in division (/) at ./multi-bleu.perl line 116, <STDIN> line 1.

So it's impossible to evaluate it?
Any suggestion will be appreciated.

_______________________________________________
Moses-support mailing list
Moses-support@...
http://mailman.mit.edu/mailman/listinfo/moses-support
Philipp Koehn | 10 Jul 2012 07:38
Picon
Picon
Favicon

Re: Can't evaluate the BLEU score for single sentence pairs

Hi,

since the BLEU score is based on the geometric mean between 1 to 4-gram
precision, this often fails for single sentences. (no 4-gram match means
multiplying with 0).

One remedy is to add 1 to all precision counts, but this fix is not implemented
in any of the standard BLEU scorers.

-phi

On Mon, Jul 9, 2012 at 10:27 PM, Loki Cheng <moonloki@...> wrote:
> Hi, all
> I can't evaluate the BLEU score for single sentence pairs with
> multi-bleu.perl. I don't know why? example just like below:
>
> Original Chinese sentence: 安理會 還 請 建設 和平 委員會 向 安理會 提供 咨詢
意見 。
> English translation result: 安理會 還 請 建設 和平 委員會 提供 咨詢 意見 的
委員會 。
>
> error message: Use of uninitialized value in division (/) at
> ./multi-bleu.perl line 116, <STDIN> line 1.
>
> So it's impossible to evaluate it?
> Any suggestion will be appreciated.
>
> _______________________________________________
> Moses-support mailing list
> Moses-support@...
> http://mailman.mit.edu/mailman/listinfo/moses-support
>

_______________________________________________
Moses-support mailing list
Moses-support@...
http://mailman.mit.edu/mailman/listinfo/moses-support
John Dimm | 3 Dec 2012 05:56
Favicon

Re: Can't evaluate the BLEU score for single sentence pairs

Philipp Koehn <pkoehn <at> ...> writes:

> 
> Hi,
> 
> since the BLEU score is based on the geometric mean between 1 to 4-gram
> precision, this often fails for single sentences. (no 4-gram match means
> multiplying with 0).
> 
> One remedy is to add 1 to all precision counts, but this fix is not 
implemented
> in any of the standard BLEU scorers.
> 
> -phi
> 
> On Mon, Jul 9, 2012 at 10:27 PM, Loki Cheng <moonloki <at> ...> wrote:
> > Hi, all
> > I can't evaluate the BLEU score for single sentence pairs with
> > multi-bleu.perl. I don't know why? example just like below:
> >
> > Original Chinese sentence: 安理會 還 請 建設 和平 委員會 向 安理會 提供 咨詢
> 意見 。
> > English translation result: 安理會 還 請 建設 和平 委員會 提供 咨詢 意見 的
> 委員會 。
> >
> > error message: Use of uninitialized value in division (/) at
> > ./multi-bleu.perl line 116, <STDIN> line 1.
> >
> > So it's impossible to evaluate it?
> > Any suggestion will be appreciated.
> >
> > _______________________________________________
> > Moses-support mailing list
> > Moses-support <at> ...
> > http://mailman.mit.edu/mailman/listinfo/moses-support
> >
> 
> 
> 
> _______________________________________________
> Moses-support mailing list
> Moses-support <at> ...
> http://mailman.mit.edu/mailman/listinfo/moses-support
> 

There is also a simple bug with this error message.  For single sentence pairs, 
it doesn't make sense to calculate the confidence interval by looking at 
samples.  

my $ecart=0;
my $sample=20;
my $s=($#HYP+1);
if ($s >= $sample) { # Don't bother calculating ecart for small files.
  for(my $n=0;$n<$sample;$n++) {
      my $min = ($n*$s)/$sample;
      my $max = (($n+1)*$s)/$sample;
      my $sc=calculate_bleu($min, $max);
      $sc=~/BLEU = (.*?),/;
      if (abs($1-$BLEU)>$ecart) { $ecart=abs($1-$BLEU); }
  }
  $ecart=sprintf("%.2f",$ecart);
  $SCORE=~s/(BLEU = .*?),/$1 +\/- $ecart,/;
}

For the two Chinese sentences,

BLEU = 45.65, 83.3/54.5/40.0/33.3 (BP=0.920, ratio=0.923, hyp_len=12, 
ref_len=13)

  John

_______________________________________________
Moses-support mailing list
Moses-support <at> mit.edu
http://mailman.mit.edu/mailman/listinfo/moses-support
Tom Hoar | 10 Jul 2012 08:40

Re: Can't evaluate the BLEU score for single sentence pairs

Hi Loki,

I was able to replicate your problem with this command line:

~$ echo "安理會 還 請 建設 和平 委員會 提供 咨詢 意見 的 委員會  。" | ./multi-bleu.perl "安理會 還 請 建設 和平 委員會 向 安理會 提供 咨詢 意見 。"
Use of uninitialized value in division (/) at multi-bleu.perl line 125, <STDIN> line 1.
Use of uninitialized value in division (/) at multi-bleu.perl line 125, <STDIN> line 1.
Use of uninitialized value in division (/) at multi-bleu.perl line 125, <STDIN> line 1.
Use of uninitialized value in division (/) at multi-bleu.perl line 125, <STDIN> line 1.
BLEU = 0.00, 0.0/0.0/0.0/0.0 (BP=0.000, ratio=0.001, hyp_len=12, ref_len=9999)

But, mult-bleu.perl doesn't work that way. When I saved your original and result phases as the only lines in two files: ref.txt and tst.txt. Then, ran this command and got this result:

~$ ./multi-bleu.perl ref.txt < tst.txt
BLEU = 54.52, 83.3/63.6/50.0/33.3 (BP=1.000, ratio=1.000, hyp_len=12, ref_len=12)

Tom

 

On Tue, 10 Jul 2012 13:27:34 +0800, Loki Cheng <moonloki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Hi, all
I can't evaluate the BLEU score for single sentence pairs with multi-bleu.perl. I don't know why? example just like below:

Original Chinese sentence: 安理會 還 請 建設 和平 委員會 向 安理會 提供 咨詢 意見 。
English translation result: 安理會 還 請 建設 和平 委員會 提供 咨詢 意見 的 委員會 。

error message: Use of uninitialized value in division (/) at ./multi-bleu.perl line 116, line 1.

So it's impossible to evaluate it?
Any suggestion will be appreciated.

_______________________________________________
Moses-support mailing list
Moses-support@...
http://mailman.mit.edu/mailman/listinfo/moses-support

Gmane