in 3_optimization-design-ptn/03_prompt-optimization/promptwizard/glue/promptopt/techniques/critique_n_refine/core_logic.py [0:0]
def select_top_prompts(self, prompt_score_list: List, top_n: int) -> List:
"""
Sort prompts in prompt_score_list, based on its performance. And return max, top `top_n` prompts.
:param prompt_score_list: List of (prompt string, score for that prompt string,
set of examples given in context)
:param top_n: Max number of prompts from the top of the list, that we need to return
:return: List of top `top_n` prompts.
"""
sorted_prompts = sorted(
prompt_score_list,
key=lambda x: [
x[self.GetPromptScoreIndex.SCORE],
len(x[self.GetPromptScoreIndex.PROMPT_STR]),
],
reverse=True,
)
sorted_top_n_prompts = sorted_prompts[:top_n]
self.logger.debug(f"Sorted top n prompts: {sorted_top_n_prompts}")
return sorted_top_n_prompts