# Run\_qa.py for Tensorflow does not save the model in output directory

**URL:** <https://discuss.huggingface.co/t/run-qa-py-for-tensorflow-does-not-save-the-model-in-output-directory/14815>\
**Category:** Beginners\
**Created:** [February 17, 2022, 10:23am UTC](https://discuss.huggingface.co/t/run-qa-py-for-tensorflow-does-not-save-the-model-in-output-directory/14815 "2022-02-17T10:23:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andranik](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/andranik/32/4043_2.png) [@Andranik](https://discuss.huggingface.co/u/Andranik)\
**Post date:** [February 17, 2022, 10:23am UTC](https://discuss.huggingface.co/t/run-qa-py-for-tensorflow-does-not-save-the-model-in-output-directory/14815/1 "2022-02-17T10:23:58Z")

</div>

I am very new to the topic so sorry if the question is dumb.

I am trying to train a Q/A model with [example script for Question Answering for Tensorflow](https://github.com/huggingface/transformers/blob/master/examples/tensorflow/question-answering/run_qa.py).  
I use the following command to run the script:

```auto
python run_qa.py \
--model_name_or_path distilbert-base-cased \
--output_dir output \
--dataset_name squad \
--max_train_samples 40 \
--max_eval_samples 20 \
--do_train \
--do_eval \

```

And seems that everything goes fine and without errors, but after the script finishes the training I cannot find the trained model in output directory, what I see there are these two file `eval_nbest_predictions.json` and `eval_predictions.json` .  
So what am I doing wrong? How can I make the script save the trained model in the output directory?

---

<div class="post-metadata">

**Author:** ![raok95](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@raok95](https://discuss.huggingface.co/u/raok95)\
**Post date:** [May 29, 2022, 11:01pm UTC](https://discuss.huggingface.co/t/run-qa-py-for-tensorflow-does-not-save-the-model-in-output-directory/14815/2 "2022-05-29T23:01:04Z")

</div>

@Andranik I am facing the same outcome. Were you able to identify the root cause?

---

<div class="post-metadata">

**Author:** ![merve](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/merve/32/49809_2.png) [@merve](https://discuss.huggingface.co/u/merve)\
**Post date:** [June 3, 2022, 12:50pm UTC](https://discuss.huggingface.co/t/run-qa-py-for-tensorflow-does-not-save-the-model-in-output-directory/14815/3 "2022-06-03T12:50:43Z")

</div>

Hello there 👋

I realized what was wrong, and you can open a PR to fix it as well.  
The saving is done under [this callback](https://github.com/huggingface/transformers/blob/babeff5524bf3d5d62cfa70e1297158a755b0810/examples/tensorflow/question-answering/run_qa.py#L216). The callback should’ve been instantiated and called inside `model.fit()` but it doesn’t. I’ll open a PR to fix that (but you can also use this quick fix).
