# Automatically run train command

**URL:** <https://support.prodi.gy/t/automatically-run-train-command/4240>\
**Category:** Uncategorized\
**Tags:** usage, database\
**Created:** [May 18, 2021, 10:43am UTC](https://support.prodi.gy/t/automatically-run-train-command/4240 "2021-05-18T10:43:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhav](https://avatars.discourse-cdn.com/v4/letter/v/c68b51/32.png) [@vaibhav](https://support.prodi.gy/u/vaibhav)\
**Post date:** [May 18, 2021, 10:43am UTC](https://support.prodi.gy/t/automatically-run-train-command/4240/1 "2021-05-18T10:43:42Z")

</div>

Hi

I dont know whether what I am trying to do is possible within prodigy or not, so please let me know.

What my ask here is that suppose I am working with ner.manual command with prodigy and have annotated suppose 500 paragraphs. Now I need prodigy to automatically run the train command on this annotated data and evaluate the model and store it along with the statistics in my local pc location. Also, when I again annotate 500 paragraphs, (in total now 1000 paragraphs annotated), I want this process to repeat, i.e., run the train command on already trained model and evaluate the model again and store it with some other name and statistics as well. Again repeat this process after 500 annotations.

Is it really possible or am I am being too ambitious?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [May 19, 2021, 4:17am UTC](https://support.prodi.gy/t/automatically-run-train-command/4240/2 "2021-05-19T04:17:56Z")

</div>

Hi! Just to make sure I understand the idea correctly, you want this to kinda happen automatically in the background, right?

It should definitely be possible to set this up, it just comes down to finding a clever solution that works and is efficient. The main thing to consider is that you probably want to run the training in a separate process, or even on a separate machine. In theory, you could make your recipe's `update` method check the count of the current dataset and trigger the training, even in a subprocess. But this can easily slow down your machine or get messy if something fails because it's all in a subprocess.

A potentially better option would be to have an external service that connects to your DB and keeps checking the dataset count ([`db.count_dataset`](https://prodi.gy/docs/api-database#count-dataset)) every X seconds and starts your training and data export if you have 500 examples, and so on. If you want to run it on a different machine, e.g. a server, you could use a shared remote database like MySQL or PostgreSQL, and connect to it from the annotation machine _and_ the training machine.

---

<div class="post-metadata">

**Author:** ![vaibhav](https://avatars.discourse-cdn.com/v4/letter/v/c68b51/32.png) [@vaibhav](https://support.prodi.gy/u/vaibhav)\
**Post date:** [May 20, 2021, 11:42am UTC](https://support.prodi.gy/t/automatically-run-train-command/4240/3 "2021-05-20T11:42:52Z")

</div>

Thanks Ines! I will try this out.
