# Update train\_dataset after trainer is initialized

**URL:** <https://discuss.huggingface.co/t/update-train-dataset-after-trainer-is-initialized/5135>\
**Category:** Beginners\
**Created:** [March 27, 2021, 1:16am UTC](https://discuss.huggingface.co/t/update-train-dataset-after-trainer-is-initialized/5135 "2021-03-27T01:16:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrRobot](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@MrRobot](https://discuss.huggingface.co/u/MrRobot)\
**Post date:** [March 27, 2021, 1:16am UTC](https://discuss.huggingface.co/t/update-train-dataset-after-trainer-is-initialized/5135/1 "2021-03-27T01:16:37Z")

</div>

I am trying to fine-tune BERT for token classification under the low-resource setting, where I am aiming to use as few samples as possible (this setting is also called [active learning](https://en.wikipedia.org/wiki/Active_learning_(machine_learning))). The pipeline is like following

- Step 1: Train on initial labeled training set
- Step 2: Repeat until the annotation budget is reached or performance is good enough
  - Add annotated samples to training set based on some criterion
  - Retrain the model on the previously saved checkpoints

I have tried the following two implementations

- Initialize `Trainer(...)` every time in Step 2. _However_, this will cause the model to fine-tune from scratch and therefore seems to be incorrect.
- Update `train_dataset` after the `Trainer(...)` is initialized. _However_, from the [doc](https://huggingface.co/transformers/main_classes/trainer.html#id1), it seems that there is **no** way to update `train_dataset` after the class is initialized.

Could someone help me with this (two _howevers_). Thank you for any input!
