# Wandb for Huggingface Trainer saves only first model

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-for-huggingface-trainer-saves-only-first-model%2F16980%3E%5C
**Category:** 🤗Transformers\
**Created:** [April 19, 2022, 3:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-for-huggingface-trainer-saves-only-first-model%2F16980 "2022-04-19T15:48:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishnagarg09](https://avatars.discourse-cdn.com/v4/letter/k/edb3f5/32.png) [@krishnagarg09](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkrishnagarg09)%5C
**Post date:** [April 19, 2022, 3:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-for-huggingface-trainer-saves-only-first-model%2F16980%2F1 "2022-04-19T15:48:44Z")

</div>

I am finetuning multiple models using for loop as follows.

```auto
for file in os.listdir(args.data_dir):
    finetune(args, file)

```

BUT `wandb` shows logs only for the first file in `data_dir` although it is training and saving models for other files. It feels very strange behavior.

```auto
wandb: Synced bertweet-base-finetuned-file1: https://wandb.ai/ ***/huggingface/runs/***

```

This is a small snippet of **finetuning** code with Huggingface:

```auto
def finetune(args, file):
    training_args = TrainingArguments(
        output_dir=f'{model_name}-finetuned-{file}',
        overwrite_output_dir=True,
        evaluation_strategy='no',
        num_train_epochs=args.epochs,
        learning_rate=args.lr,
        weight_decay=args.decay,
        per_device_train_batch_size=args.batch_size,
        per_device_eval_batch_size=args.batch_size,
        fp16=True, # mixed-precision training to boost speed
        save_strategy='no',
        seed=args.seed,
        dataloader_num_workers=4,
    )

    trainer = Trainer(
        model=model,
        args=training_args,
        train_dataset=tokenized_dataset['train'],
        eval_dataset=None,
        data_collator=data_collator,
    )
    trainer.train()
    trainer.save_model()

```
