(classnames, topk=1, suffix='.')
| 88 | return prompt_templates |
| 89 | |
| 90 | def prompt_engineering(classnames, topk=1, suffix='.'): |
| 91 | prompt_templates = get_prompt_templates() |
| 92 | temp_idx = np.random.randint(min(len(prompt_templates), topk)) |
| 93 | |
| 94 | if isinstance(classnames, list): |
| 95 | classname = random.choice(classnames) |
| 96 | else: |
| 97 | classname = classnames |
| 98 | |
| 99 | return prompt_templates[temp_idx].replace('.', suffix).format(classname.replace(',', '').replace('+', ' ')) |
no test coverage detected