openai-cookbook icon indicating copy to clipboard operation
openai-cookbook copied to clipboard

Initial commit of reranking with cross-encoder cookbook

Open colin-openai opened this issue 2 years ago • 3 comments
trafficstars

colin-openai avatar Jun 08 '23 09:06 colin-openai

Hi, it looks good to me in general. One corner case I'm thinking is that the model might output the next most probable token not in ['yes','no'] (I expect this to happen at an extremely low frequency). In this case, we might need to take out the logits for ['yes','no'] then perform a softmax as post-processing.

juntang-zhuang avatar Jun 08 '23 19:06 juntang-zhuang

Hi, it looks good to me in general. One corner case I'm thinking is that the model might output the next most probable token not in ['yes','no'] (I expect this to happen at an extremely low frequency). In this case, we might need to take out the logits for ['yes','no'] then perform a softmax as post-processing.

Two options here, since you cannot grab the full distribution:

  • Use logit_bias to massively upweight the ' yes' and ' no' tokens (better if you need both tokens)
  • Use echo=True to always get the logprob for ' yes' (better if you just need ' yes')

ted-at-openai avatar Jun 10 '23 00:06 ted-at-openai

@ted-at-openai @juntang-zhuang updated with logit bias for Yes and No, seems to work well. Let me know if there is any other feedback, otherwise ready to merge.

colin-openai avatar Jun 15 '23 14:06 colin-openai

@ted-at-openai thanks for reviewing, I've left open the ones that need an extra check on how I've responded - once you're happy I'll merge.

colin-openai avatar Jun 26 '23 10:06 colin-openai

Looks great. Only two final recommendations:

  • Use a big logit_bias (e.g., 100 instead of 1; 1 is small enough that a lot of other tokens will still come in, which explains why you saw 'No' outranking ' Yes' sometimes)
  • Rerun all the cells at the end so they're in numerical order (without any distracting jumps from 5 to 30 where someone wonders what the author was doing for those 25 steps in between :) )

ted-at-openai avatar Jun 27 '23 23:06 ted-at-openai