peal.teachers.teacher_factory.get_teacher¶
- peal.teachers.teacher_factory.get_teacher(teacher, output_size, adaptor_config, dataset, device=torch.device, tracking_level=0, counterfactual_type='1sided')[source]¶
Build the teacher described by
teacher.The accepted specifications are, in dispatch order:
a
TeacherInterfaceinstance, returned unchanged;an
nn.Module, wrapped as an eval-modeModel2ModelTeacher;a dict with
type: symbolic(modelpath,confounder_name),type: llm(LLM2ModelTeacherdriven by aclaude -psubprocess),type: web(WebFeedbackTeacherpolling a directory) ortype: NoisyModel2Model(modelpath,noise_prob);strings
"web:<dir>","preclustered"(usesadaptor_config.correct_clusters),"cluster[XXXX]","virelay[XXXX]","human[XXXX]"(XXXXan optional four digit port, default 8000),"SegmentationMask"(usesadaptor_config.attribution_threshold),"Baseline:<strategy>"and a*.cplpath to a torch-saved oracle model.
Saved models are loaded with
torch.loadand fall back toweights_only=Falsewhen the default load fails.- Parameters:
teacher (
TeacherInterfaceornn.Moduleorstrordict) – Teacher specification as listed above.output_size (
int) – Number of classifier outputs. Currently unused by every branch.adaptor_config (
object) – Adaptor config; onlycorrect_clustersandattribution_thresholdare read, for the preclustered and segmentation-mask teachers.dataset (
PealDataset) – Dataset the teacher judges counterfactuals of.device (
torch.deviceorstr, optional) –map_locationfortorch.load. Defaults to CPU.tracking_level (
int, optional) – Verbosity of intermediate artifacts, forwarded to the teacher.counterfactual_type (
str, optional) –"1sided"or"2sided", forwarded to the teacher.
- Returns:
The constructed teacher.
- Return type:
TeacherInterface- Raises:
ValueError – If
teachermatches none of the specifications.