FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

About temperature, query_instruction_for_retrieval and passage_instruction_for_retrieval?

Open chuan298 opened this issue 1 year ago • 2 comments

Hi guys, thanks for your great repo. I want to ask some question

  1. What is the similarity distribution of model when I set temperature = 0.02? Previously, I saw you say that when temperature=0.01, the similarity distribution is [0.6, 1].
  2. I fine-tuned model with query_instruction_for_retrieval="query: " and passage_instruction_for_retrieval="passage: ", so do I also need add them when inference?

chuan298 avatar Jan 19 '24 07:01 chuan298

Hi, thanks for your interest in our work!

  1. The standard cosine similarity ranges from -1 to 1. A higher temperature coefficient will make the model's score range closer to the standard range. In our experience, the similarity range for bge-zh-v1.5 is between 0.2 and 1, while for bge-en-v1.5, it is between 0.4 and 1.
  2. yes, you should set the same instruction for inference if you use instruction in fine-tuning.

staoxiao avatar Jan 19 '24 10:01 staoxiao

Hi, thanks for your interest in our work!

  1. The standard cosine similarity ranges from -1 to 1. A higher temperature coefficient will make the model's score range closer to the standard range. In our experience, the similarity range for bge-zh-v1.5 is between 0.2 and 1, while for bge-en-v1.5, it is between 0.4 and 1.
  2. yes, you should set the same instruction for inference if you use instruction in fine-tuning.

Hi,

"The standard cosine similarity ranges from -1 to 1. A higher temperature coefficient will make the model's score range closer to the standard range."

When I use bge-en-v1.5, I found the cosine similarity score typically ranging between 0.4 and 1. (So two random documents will have 0.4 similarity which is kind of counter-intuititve)

So why use tempreture to "reshape" the similarity distribution? Why not keep it ranges from -1 to 1, which seems to be more intuitive and clear for revealing the negative/positive relationship between documents?

dayuyang1999 avatar Jul 30 '24 00:07 dayuyang1999