Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion scripts/run_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def parse_and_validate_args():
help="Whether to load the model using Flash Attention 2",
action="store_true",
)
parser.add_argument(
"--base_model_name_or_path",
help="Base model for adapter",
)
parsed_args = parser.parse_args()

print(f"Multiclass / multioutput delimiter: {parsed_args.delimiter}")
Expand Down Expand Up @@ -446,7 +450,20 @@ def export_experiment_info(

if __name__ == "__main__":
args = parse_and_validate_args()
tuned_model = TunedCausalLM.load(args.model, use_flash_attn=args.use_flash_attn)

base_model_name_or_path = args.base_model_name_or_path
if not base_model_name_or_path:
adapter_config_path = os.path.join(args.model, "adapter_config.json")
if os.path.exists(adapter_config_path):
with open(adapter_config_path, "r", encoding="utf-8") as config_file:
adapter_config = json.load(config_file)
base_model_name_or_path = adapter_config.get("base_model_name_or_path")

tuned_model = TunedCausalLM.load(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, this code is missing the case that a user is running evaluation on a fine tuned model and there's no adapter_config.json file and they don't pass in any value for base_model_name_or_path. Then the model will fail to load, and an exception is raised, is that correct?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, the problem is that fine tuned models don't have an adapter_config.json nor is a base model needed to load the model. So this may be another bug in the run_inference script for fine tuned models that needs to be fixed. Let me try it out with fine tuned model...

@anhuong anhuong Aug 8, 2024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aluu317 verified that both changes did not affect the fine tuning case. No change is needed for fine tuning because of this line in TunedCausalLM.load(). Since no adapter_config.json is found, this jumps below to the except block where the model is correctly loaded as a merged model. Thus am able to run_evaluation with fine tuned models.

args.model,
use_flash_attn=args.use_flash_attn,
base_model_name_or_path=base_model_name_or_path,
)
eval_data = datasets.load_dataset(
"json", data_files=args.data_path, split=args.split
)
Expand Down