useful-transformers icon indicating copy to clipboard operation
useful-transformers copied to clipboard

LayerNorm_A calculation precision is unstable, leading to incorrect recognition results.

Open winf opened this issue 1 year ago • 2 comments

#41 #20 When using models other than .en, if the model size exceeds ‘tiny’, the recognition results are found to be significantly incorrect. By comparing the layer-by-layer outcomes with the openai repository’s runtime results, it was ultimately determined that the source of the problem is the poor stability of mean and variance calculations in the LayerNorm_A function. I fixed the issue by replacing fp16 with fp32. Reference: https://git.bwbot.org/publish/useful-transformers/-/blob/main/lib/layernorm.cc

winf avatar Aug 02 '24 02:08 winf

@marty1885 @guynich

winf avatar Aug 02 '24 02:08 winf

Thank you! This solves my problems too!

I don't have write access to the repository. Maybe you could make a PR and upstream the changes? I can test on my end.

marty1885 avatar Aug 02 '24 05:08 marty1885