class autonlu.finetuning.LMTeacher(load_location, save_location=None, nb_loaded_versions=None, nb_save_versions=None, Xtrain=None, Ytrain=None, Xvalid=None, Yvalid=None, training_epochs=10, new_teacher_time_interval=3600, nb_label=4, nb_aspects=None, verbose=True)

The LMTeacher class encapsulates all information needed for LM finetuning of autonlu.SimpleModel with a teacher (task: prelabeled).

The training can use several teachers scattered over different folders. Therefore, the class requires a list of load_location. One might also generate a new teacher after certain time intervals (given by new_teacher_time_interval in seconds). For the new teacher, one has to specify the path save_location. Usually, with each saving of a new teacher an older teacher is overwritten. One can keep more than one teacher by specifying nb_save_versions. If this value is set, teachers are saved in subdirectories called “version” + integer, with integer <= nb_save_versions. When all subdirectories are used, the oldest teacher is overwritten when a new teacher is saved.

Since saving more than one teacher is possible, it’s also possible to load more than one model from each path specified in load_location (provided the models are saved in subdirectories named “version” + integer, as done when teachers are spawned during finetuning). To this end, one might specify nb_loaded_versions as list of integers of the same length as the list load_location. Each entry in nb_loaded_versions corresponds to the path with the same index in load_location. To spawn a new teacher, labeled trainings and validation data is needed. These are provided by Xtrain, Ytrain, Xvalid, Yvalid.

  • load_location (List[str]) – List of folders, where teachers used for finetuning can be found.

  • save_location (Optional[str]) – Path to folder. If new teachers are created, they are saved in this folder The default value is None. In this case, no new teachers are created.

  • nb_loaded_versions (Optional[List[int]]) – Each element in this list corresponds to the folder with the same index in load_location and specifies how many teacher models found in the folder should be used. If set, it is assumed that the teacher models are found in subdirectories called “version” + integer. If a list element is set to None, it is assumed that there are no “version” + integer subdirectories. Instead, it is assumed that the folder contains exactly one model (directly - not in subdirectories). Setting the entire nb_loaded_versions to None is the same as a list with only None entries.

  • nb_save_versions (Optional[int]) – Only relevant if save_location is not None. Number of subdirectories “version” + integer used to store new teacher models. If set to None, no extra subdirectories are created and the teacher model is saved directly into the folder save_location.

  • Xtrain (Optional[List[Union[str, Tuple[str, str]]]]) – Training examples used for teacher training. Only relevant if save_location is not None.

  • Ytrain (Optional[List[str]]) – Labels for the training examples used in teacher training. Only relevant if save_location is not None.

  • Xvalid (Optional[List[Union[str, Tuple[str, str]]]]) – Validation samples used to judge the quality of new teacher models. Only relevant if save_location is not None.

  • Yvalid (Optional[List[str]]) – Labels for the validation samples used to judge the quality of new teacher models. Only relevant if save_location is not None.

  • training_epochs (int) – Maximal number of epochs used for the training of new teachers. Only relevant if save_location is not None.

  • new_teacher_time_interval (float) – Specifies the time intervals after which new teachers are generated. Only relevant if save_location is not None.

  • nb_label (int) – Number of labels

  • nb_aspects (Optional[int]) – Number of aspects

  • verbose (bool) – If True, information about the training progress will be shown on the terminal.