INNER CODE UNIT · Python
display_performance
liyucheng09/Selective_Context · main.py:15
def display_performance(context: ContextAndAnswer):
assert context.metrics is not None, 'Not evaluted yet!'
metric_result = '\n'.join([f'{k}: {v}' for k, v in context.metrics.items()])
logging.info(f'Performance summary:\ntask type: {context.task_name}\ndataset type: {context.dataset_type}\nMask_ratio: {context.mask_ratio}\nMetrics: {metric_result}\n')
print(f'\nPerformance summary:\ntask type: {context.task_name}\ndataset type: {context.dataset_type}\nMask_ratio: {context.mask_ratio}\nMetrics: {metric_result}\n')
def main():
arxiv_path, news_path, conversation_path, save_to_path, num_articles, model_name = sys.argv[1:]
logging.basicConfig(level=logging.INFO, filename=os.path.join(save_to_path, f'log_{model_name}.txt'), filemode='w', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.info(f'arxiv_path: {arxiv_path}, news_path: {news_path}, conversation_path: {conversation_path}, save_to_path: {save_to_path}, num_articles: {num_articles}, model_name: {model_name}, task_name: {task_name}')
num_articles = int(num_articles)
# task_types = ['summarisation', 'masked-targeting-qa', 'qa']
# mask_types = ['self-info-sentence', 'Ramdom', 'no']
mask_types = ['no', 'self-info', 'Random']
# mask_types = ['no', 'self-info', 'Random', 'no2']
mask_levels = ['phrase', ]