How to save finetuned HuggingFace models in AzureML job

matsuo_basho 30 Reputation points
2023-11-16T18:29:02.12+00:00

I launch an AzureML job that finetunes a HuggingFace model through the CLI. The model is a text generation model, so I cannot use the finetune pipeline from the model registry. I can't figure out how to actually save the finetuned model to a blobstore.

Below is the part of the code where the model is saved. This works locally, but I'm unable to find the output anywhere after the job runs if run like this in AzureML.

``

    trainer = Trainer(
        model,
        training_args,
        train_dataset=tokenized_dataset['train'],
        eval_dataset=tokenized_dataset['test'],
        data_collator=data_collator,
        tokenizer=tokenizer)

    trainer.train()

    trainer.save_model()

I also tried passing the model_dir argument to save_model, but that didn't work. For reference, the base model I'm using: Salesforce/codegen-350M-mono

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,835 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.