How I design the result score(Or result probability) ,as the example shows ?

#7
by luojiluoji - opened

When I fine tune this model (like layoutlm or other versions),the layoutlm output has no probability, but I want to show the probability for the question like the example does. Can you guide me how to design the probability for the question? Thanks a lot.
image.png

Impira org

Hi there, can you provide some more details (e.g. code)? The model's outputs are logits from which you can compute confidence, and it's not clear to me why finetuning changes that. I.e. after you fine tune the model, you should be able to compute exactly the same outputs.

Hi there, can you provide some more details (e.g. code)? The model's outputs are logits from which you can compute confidence, and it's not clear to me why finetuning changes that. I.e. after you fine tune the model, you should be able to compute exactly the same outputs.

thanks for your reply,I mean,like the example code,the same question,the nlp return the score is 0.9943977,and the right side ,the page return the score is 0.425, which one should I trust?
Deeply, I have a question: the outputs are logits for the begin and end position of the inputs, but how to transform the logits to score(probability)? Use softmax?

image.png

for example. I got the outputs logits for the answer start position, and I do softmax for the logits.and got the max probability is 0.6064619. And I do the softmax for the outputs logits for the answer end position. I got the max probability is 0.41881067.should the final probability is (0.6064619 +0.41881067 )/2 = 0.512636285?

image.png

Looking forward to your answers. Thanks a lot

Impira org

I would suggest reading this code, which transforms the outputs from the model into the scores you see in the demo:

https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/document_question_answering.py#L450

I would suggest reading this code, which transforms the outputs from the model into the scores you see in the demo:

https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/document_question_answering.py#L450

Thanks,I see the code and debug carefully, now I know : to be simple ,if the max end logits index bigger than the start logits index, which means find the answer , the final score is just the start.max()*end.max(), They just multiply.
that's really me ,thank you.

luojiluoji changed discussion status to closed
Impira org

Sorry I'm not sure I follow — the link you pasted is loading for me?

Sign up or log in to comment