INNER CODE UNIT · Python

save_as_pickle

liyucheng09/Selective_Context · main.py:10

def save_as_pickle(obj, file_path):
    with open(file_path, 'wb') as f:
        pickle.dump(obj, f)
    logging.info(f'Saved to {file_path}')

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']

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…