sacrebleu icon indicating copy to clipboard operation
sacrebleu copied to clipboard

Add optimization for compute_bleu precision initialization

Open ernlavr opened this issue 2 years ago • 0 comments

Description: Added a one-line optimization for initialization of the precissions list in def compute_bleu function.

Motivation: I have to do a total of 7 billion computations so I was looking at possibilities for optimizing the computation routine. I find that this change is about x4 faster for the operation, consisting of about 12% of total improvement for the function. Added a screenshots of my timings. See the diff between precissions_old and precissions_optim. Numbers are averaged over 10k computations.

image

P.s. this change is also reflected in this StackOverflow post https://stackoverflow.com/questions/20816600/best-and-or-fastest-way-to-create-lists-in-python

ernlavr avatar Feb 22 '24 15:02 ernlavr