repair bleu score computation (#14626)

pull/14635/head
liuhongen1234567 2025-02-06 16:02:59 +08:00 committed by GitHub
parent ebd08eb385
commit 2c0c4beb06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 6 deletions

View File

@ -69,7 +69,7 @@ PostProcess:
Metric:
name: LaTeXOCRMetric
main_indicator: exp_rate
cal_bleu_score: False
cal_bleu_score: True
Train:
dataset:

View File

@ -53,7 +53,7 @@ Architecture:
encoder_hidden_size: 2048
is_export: False
length_aware: True
use_parallel: True,
use_parallel: True
parallel_step: 3
Loss:
@ -67,7 +67,7 @@ PostProcess:
Metric:
name: LaTeXOCRMetric
main_indicator: exp_rate
cal_bleu_score: False
cal_bleu_score: True
Train:
dataset:

View File

@ -66,7 +66,7 @@ PostProcess:
Metric:
name: LaTeXOCRMetric
main_indicator: exp_rate
cal_bleu_score: False
cal_bleu_score: True
Train:
dataset:

View File

@ -66,7 +66,7 @@ PostProcess:
Metric:
name: LaTeXOCRMetric
main_indicator: exp_rate
cal_bleu_score: False
cal_bleu_score: True
Train:
dataset:

View File

@ -98,7 +98,10 @@ def compute_bleu(reference_corpus, translation_corpus, max_order=4, smooth=False
else:
geo_mean = 0
ratio = float(translation_length) / reference_length
if float(translation_length) == 0 or float(reference_length) == 0:
ratio = 1e-5
else:
ratio = float(translation_length) / reference_length
if ratio > 1.0:
bp = 1.0