# Ensemble with \`trainer\`

**URL:** <https://discuss.huggingface.co/t/ensemble-with-trainer/3763>\
**Category:** Beginners\
**Created:** [February 20, 2021, 9:58pm UTC](https://discuss.huggingface.co/t/ensemble-with-trainer/3763 "2021-02-20T21:58:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neel-Gupta](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@Neel-Gupta](https://discuss.huggingface.co/u/Neel-Gupta)\
**Post date:** [February 20, 2021, 9:58pm UTC](https://discuss.huggingface.co/t/ensemble-with-trainer/3763/1 "2021-02-20T21:58:50Z")

</div>

Can anyone inform me whether we can use `trainer` for ensembling 2 HuggingFace models? I want to fine-tune them both but want them to work as an ensemble without going much deep in the code. Is that possible?

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [February 21, 2021, 2:59pm UTC](https://discuss.huggingface.co/t/ensemble-with-trainer/3763/2 "2021-02-21T14:59:14Z")

</div>

No, the Trainer is there to quickly train/fine-tune one model, so you can apply it to your two models separately (and have two trainers) but you will then need to do the ensembling manually. If you just want to average the predictions you can call the predict method of each trainer on your data and then average the results.

---

<div class="post-metadata">

**Author:** ![Neel-Gupta](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@Neel-Gupta](https://discuss.huggingface.co/u/Neel-Gupta)\
**Post date:** [February 21, 2021, 4:31pm UTC](https://discuss.huggingface.co/t/ensemble-with-trainer/3763/3 "2021-02-21T16:31:04Z")

</div>

I suppose that’s a workaround. Sad that HF does not allow ensembling ☹ . Proper ensembling support is always good
