taokz / BiomedGPT

BiomedGPT: A Unified and Generalist Biomedical Generative Pre-trained Transformer for Vision, Language, and Multimodal Tasks
Apache License 2.0
363 stars 34 forks source link

Pretrained-base higher than finetuned-base on Slake #20

Closed JennDong closed 4 months ago

JennDong commented 4 months ago

I test the shared checkpoints without any tuning and get the following results. I am confused to see that pretrained-base performs better than finetuned-base on Slake. Also, as I set different seeds while inference, the results don't change.

Exact Match Score | Finetuned-Base-Slake | Finetuned-Base-VQARAD | Pretrained-Base-Slake | Pretrained-Base-VQARAD -- | -- | -- | -- | -- Overall | 0.8576814326107446 | 0.9301601423487544 | 0.8850141376060321 | 0.29359430604982206 Open Questions | 0.8232558139534883 | 0.8914646996838778 | 0.8651162790697674 | 0.037934668071654375 Closed Questions | 0.9110576923076923 | 0.9591049382716049 | 0.9158653846153846 | 0.48033924441017734

taokz commented 4 months ago

Could you please provide additional details, such as evaluation scripts, on how you achieved these results? Specifically, regarding the pre-trained model, I'm interested to know whether the zero-shot predictions were made without label candidates or if they were conducted within the scope of constrained labels. The results you've reported appear significantly higher than what I have been able to achieve, and I'm keen to understand the discrepancy.

JennDong commented 4 months ago

Here is part of the evaluation scripts with args: CUDA_VISIBLE_DEVICES=3 python3 -m evaluate \ ${data} \ --path=${path} \ --user-dir=${user_dir} \ --task=vqa_gen \ --selected-cols=${selected_cols} \ --bpe-dir=${bpe_dir} \ --patch-image-size=${patch_image_size} \ --prompt-type='none' \ --batch-size=8 \ --log-format=simple --log-interval=100 \ --seed=1 \ --gen-subset=${split} \ --results-path=${result_path} \ --fp16 \ --zero-shot \ --beam=1 \ --unnormalized \ --temperature=1.0 \ --num-workers=0 \

${log_file} 2>&1 Here is the corresponding log file: 2024-03-29 10:35:26 | INFO | ofa.evaluate | {'_name': None, 'common': {'_name': None, 'no_progress_bar': False, 'log_interval': 100, 'log_format': 'simple', 'log_file': None, 'tensorboard_logdir': None, 'wandb_project': None, 'azureml_logging': False, 'seed': 7, 'cpu': False, 'tpu': False, 'bf16': False, 'memory_efficient_bf16': False, 'fp16': True, 'memory_efficient_fp16': False, 'fp16_no_flatten_grads': False, 'fp16_init_scale': 128, 'fp16_scale_window': None, 'fp16_scale_tolerance': 0.0, 'on_cpu_convert_precision': False, 'min_loss_scale': 0.0001, 'threshold_loss_scale': None, 'amp': False, 'amp_batch_retries': 2, 'amp_init_scale': 128, 'amp_scale_window': None, 'user_dir': '/data2/dongwenjie/BiomedGPT/module', 'empty_cache_freq': 0, 'all_gather_list_size': 16384, 'model_parallel_size': 1, 'quantization_config_path': None, 'profile': False, 'reset_logging': False, 'suppress_crashes': False, 'use_plasma_view': False, 'plasma_path': '/tmp/plasma'}, 'common_eval': {'_name': None, 'path': '/data2/dongwenjie/BiomedGPT/checkpoints/biomedgpt_base.pt', 'post_process': None, 'quiet': False, 'model_overrides': '{}', 'results_path': '/data2/dongwenjie/BiomedGPT/scripts/vqa/results/base'}, 'distributed_training': {'_name': None, 'distributed_world_size': 1, 'distributed_num_procs': 1, 'distributed_rank': 0, 'distributed_backend': 'nccl', 'distributed_init_method': None, 'distributed_port': -1, 'device_id': 0, 'distributed_no_spawn': False, 'ddp_backend': 'pytorch_ddp', 'ddp_comm_hook': 'none', 'bucket_cap_mb': 25, 'fix_batches_to_gpus': False, 'find_unused_parameters': False, 'gradient_as_bucket_view': False, 'fast_stat_sync': False, 'heartbeat_timeout': -1, 'broadcast_buffers': False, 'slowmo_momentum': None, 'slowmo_algorithm': 'LocalSGD', 'localsgd_frequency': 3, 'nprocs_per_node': 1, 'pipeline_model_parallel': False, 'pipeline_balance': None, 'pipeline_devices': None, 'pipeline_chunks': 0, 'pipeline_encoder_balance': None, 'pipeline_encoder_devices': None, 'pipeline_decoder_balance': None, 'pipeline_decoder_devices': None, 'pipeline_checkpoint': 'never', 'zero_sharding': 'none', 'fp16': True, 'memory_efficient_fp16': False, 'tpu': False, 'no_reshard_after_forward': False, 'fp32_reduce_scatter': False, 'cpu_offload': False, 'use_sharded_state': False}, 'dataset': {'_name': None, 'num_workers': 0, 'skip_invalid_size_inputs_valid_test': False, 'max_tokens': None, 'batch_size': 8, 'required_batch_size_multiple': 8, 'required_seq_len_multiple': 1, 'dataset_impl': None, 'data_buffer_size': 10, 'train_subset': 'train', 'valid_subset': 'valid', 'combine_valid_subsets': None, 'ignore_unused_valid_subsets': False, 'validate_interval': 1, 'validate_interval_updates': 0, 'validate_after_updates': 0, 'fixed_validation_seed': None, 'disable_validation': False, 'max_tokens_valid': None, 'batch_size_valid': 8, 'max_valid_steps': None, 'curriculum': 0, 'gen_subset': '', 'num_shards': 1, 'shard_id': 0}, 'optimization': {'_name': None, 'max_epoch': 0, 'max_update': 0, 'stop_time_hours': 0.0, 'clip_norm': 0.0, 'sentence_avg': False, 'update_freq': [1], 'lr': [0.25], 'stop_min_lr': -1.0, 'use_bmuf': False}, 'checkpoint': {'_name': None, 'save_dir': 'checkpoints', 'restore_file': 'checkpoint_last.pt', 'finetune_from_model': None, 'reset_dataloader': False, 'reset_lr_scheduler': False, 'reset_meters': False, 'reset_optimizer': False, 'optimizer_overrides': '{}', 'save_interval': 1, 'save_interval_updates': 0, 'keep_interval_updates': -1, 'keep_interval_updates_pattern': -1, 'keep_last_epochs': -1, 'keep_best_checkpoints': -1, 'no_save': False, 'no_epoch_checkpoints': False, 'no_last_checkpoints': False, 'no_save_optimizer_state': False, 'best_checkpoint_metric': 'loss', 'maximize_best_checkpoint_metric': False, 'patience': -1, 'checkpoint_suffix': '', 'checkpoint_shard_count': 1, 'load_checkpoint_on_all_dp_ranks': False, 'write_checkpoints_asynchronously': False, 'model_parallel_size': 1, 'use_ema_weights_to_init_param': False, 'use_latest_weights_to_init_ema': False}, 'bmuf': {'_name': None, 'block_lr': 1.0, 'block_momentum': 0.875, 'global_sync_iter': 50, 'warmup_iterations': 500, 'use_nbm': False, 'average_sync': False, 'distributed_world_size': 1}, 'generation': {'_name': None, 'beam': 1, 'nbest': 1, 'max_len_a': 0.0, 'max_len_b': 200, 'min_len': 1, 'match_source_len': False, 'unnormalized': True, 'no_early_stop': False, 'no_beamable_mm': False, 'lenpen': 1.0, 'unkpen': 0.0, 'replace_unk': None, 'sacrebleu': False, 'score_reference': False, 'prefix_size': 0, 'no_repeat_ngram_size': 0, 'sampling': False, 'sampling_topk': -1, 'sampling_topp': -1.0, 'constraints': None, 'temperature': 1.0, 'diverse_beam_groups': -1, 'diverse_beam_strength': 0.5, 'diversity_rate': -1.0, 'print_alignment': None, 'print_step': False, 'lm_path': None, 'lm_weight': 0.0, 'iter_decode_eos_penalty': 0.0, 'iter_decode_max_iter': 10, 'iter_decode_force_max_iter': False, 'iter_decode_with_beam': 1, 'iter_decode_with_external_reranker': False, 'retain_iter_history': False, 'retain_dropout': False, 'retain_dropout_modules': None, 'decoding_format': None, 'no_seed_provided': False}, 'eval_lm': {'_name': None, 'output_word_probs': False, 'output_word_stats': False, 'context_window': 0, 'softmax_batch': 9223372036854775807}, 'interactive': {'_name': None, 'buffer_size': 0, 'input': '-'}, 'model': None, 'task': {'_name': 'vqa_gen', 'data': '/data2/dongwenjie/BiomedGPT/datasets/finetuning/Slake/test.tsv', 'selected_cols': '0,5,2,3,4', 'bpe': None, 'bpe_dir': '/data2/dongwenjie/BiomedGPT/utils/BPE', 'max_source_positions': 1024, 'max_target_positions': 1024, 'max_src_length': 128, 'max_tgt_length': 30, 'code_dict_size': 8192, 'patch_image_size': 384, 'orig_patch_image_size': 256, 'num_bins': 1000, 'imagenet_default_mean_and_std': False, 'constraint_range': None, 'max_object_length': 30, 'ans2label_dict': '{"no": 0, "yes":1}', 'ans2label_file': None, 'unconstrained_training': False, 'add_object': False, 'valid_batch_size': 20, 'prompt_type': 'none', 'uses_ema': False, 'val_inference_type': 'allcand', 'eval_args': '{"beam":5,"unnormalized":true,"temperature":1.0}'}, 'criterion': {'_name': 'cross_entropy', 'sentence_avg': True}, 'optimizer': None, 'lr_scheduler': {'_name': 'fixed', 'force_anneal': None, 'lr_shrink': 0.1, 'warmup_updates': 0, 'lr': [0.25]}, 'scoring': {'_name': 'bleu', 'pad': 1, 'eos': 2, 'unk': 3}, 'bpe': None, 'tokenizer': None, 'ema': {'_name': None, 'store_ema': False, 'ema_decay': 0.9999, 'ema_start_update': 0, 'ema_seed_model': None, 'ema_update_freq': 1, 'ema_fp32': False}} 2024-03-29 10:35:26 | INFO | ofa.evaluate | loading model(s) from /data2/dongwenjie/BiomedGPT/checkpoints/biomedgpt_base.pt 2024-03-29 10:35:26 | INFO | tasks.ofa_task | source dictionary: 59457 types 2024-03-29 10:35:26 | INFO | tasks.ofa_task | target dictionary: 59457 types local datafile /data2/dongwenjie/BiomedGPT/datasets/finetuning/Slake/test.tsv slice_id 0 begin to initialize row_count and line_idx-to-offset mapping local datafile /data2/dongwenjie/BiomedGPT/datasets/finetuning/Slake/test.tsv slice_id 0 finished initializing row_count and line_idx-to-offset mapping file /data2/dongwenjie/BiomedGPT/datasets/finetuning/Slake/test.tsv slice_id 0 row count 1061 total row count 1061 2024-03-29 10:35:54 | INFO | fairseq.logging.progress_bar | : 101 / 133 sentences=8 2024-03-29 10:36:00 | INFO | ofa.evaluate | score_sum: tensor([939.], device='cuda:0'), score_cnt: tensor([1061.], device='cuda:0'), score: 0.885

taokz commented 4 months ago

@JennDong Apologies for the delay in getting back to you. Unfortunately, I haven't had access to the computing resources lately due to recents workloads for both myself and my lab colleagues. As a result, I haven't been able to check the results. However, I do have a report on the SLAKE results generated last year. In my analysis, I utilized a beam value of 20, but I didn't experiment with a beam value of 1. I think that leveraging the pre-trained model could yield better comprehension is still reasonable, especially considering that I trained it using SLAKE training set during pretraining, which also integrated with additional datasets (like MediCAT captioning data) that might further enhance the capability. Also, regarding SLAKE's zero-shot ability, I don't believe it applies since I incorporated SLAKE training set during the pretraining phase, and the test set shares similar question types and images.

023-01-20 20:37:49 | INFO | ofa.evaluate | score_sum: tensor([877.], device='cuda:0'), score_cnt: tensor([1061.], device='cuda:0'), score: 0.8266
2023-01-20 20:37:49 | INFO | torch.distributed.distributed_c10d | Added key: store_based_barrier_key:2 to store for rank: 0
2023-01-20 20:37:49 | INFO | torch.distributed.distributed_c10d | Rank 0: Completed store-based barrier for key:store_based_barrier_key:2 with 1 nodes.