- masked_inplace_autoregression(
- model,
- self.batch_size,
- quizzes,
- ar_mask,
- deterministic_synthesis=False,
- progress_bar_desc="creating quizzes",
- device=self.device,
- )
+ ar_mask = torch.full(c_quizzes.size(), 1, device=self.device)
+ seq_logproba = torch.empty(ar_mask.size(0), device=self.device)
+
+ temperature = 1
+ d_temperature = 1
+
+ while True:
+ seq_logproba[...] = 0
+
+ masked_inplace_autoregression(
+ model=model,
+ batch_size=self.batch_size,
+ input=c_quizzes,
+ ar_mask=ar_mask,
+ seq_logproba=seq_logproba,
+ temperature=temperature,
+ deterministic_synthesis=False,
+ progress_bar_desc="sampling c_quizzes",
+ device=self.device,
+ )
+
+ ave_seq_logproba = seq_logproba.mean()
+
+ logger(f"{ave_seq_logproba=} {min_ave_seq_logproba=}")
+
+ if min_ave_seq_logproba is None:
+ break
+
+ # Oh man that's ugly
+ if ave_seq_logproba < min_ave_seq_logproba * 1.1:
+ if d_temperature > 0:
+ d_temperature *= -1 / 3
+ temperature += d_temperature
+ elif ave_seq_logproba > min_ave_seq_logproba:
+ if d_temperature < 0:
+ d_temperature *= -1 / 3
+ temperature += d_temperature
+ else:
+ break
+
+ logger(f"chaging temperature to {temperature}")