LMTeacher¶
- 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.SimpleModelwith 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 bynew_teacher_time_intervalin seconds). For the new teacher, one has to specify the pathsave_location. Usually, with each saving of a new teacher an older teacher is overwritten. One can keep more than one teacher by specifyingnb_save_versions. If this value is set, teachers are saved in subdirectories called “version” +integer, withinteger<=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 specifynb_loaded_versionsas list of integers of the same length as the listload_location. Each entry innb_loaded_versionscorresponds to the path with the same index inload_location. To spawn a new teacher, labeled trainings and validation data is needed. These are provided byXtrain,Ytrain,Xvalid,Yvalid.- Parameters
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 isNone. 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 inload_locationand 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 toNone, it is assumed that there are no “version” +integersubdirectories. Instead, it is assumed that the folder contains exactly one model (directly - not in subdirectories). Setting the entirenb_loaded_versionstoNoneis the same as a list with onlyNoneentries.nb_save_versions (
Optional[int]) – Only relevant ifsave_locationis notNone. Number of subdirectories “version” +integerused to store new teacher models. If set toNone, no extra subdirectories are created and the teacher model is saved directly into the foldersave_location.Xtrain (
Optional[List[Union[str,Tuple[str,str]]]]) – Training examples used for teacher training. Only relevant ifsave_locationis notNone.Ytrain (
Optional[List[str]]) – Labels for the training examples used in teacher training. Only relevant ifsave_locationis notNone.Xvalid (
Optional[List[Union[str,Tuple[str,str]]]]) – Validation samples used to judge the quality of new teacher models. Only relevant ifsave_locationis notNone.Yvalid (
Optional[List[str]]) – Labels for the validation samples used to judge the quality of new teacher models. Only relevant ifsave_locationis notNone.training_epochs (
int) – Maximal number of epochs used for the training of new teachers. Only relevant ifsave_locationis notNone.new_teacher_time_interval (
float) – Specifies the time intervals after which new teachers are generated. Only relevant ifsave_locationis notNone.nb_label (
int) – Number of labelsnb_aspects (
Optional[int]) – Number of aspectsverbose (
bool) – IfTrue, information about the training progress will be shown on the terminal.