logitorch.pl_models.proofwriter¶
Classes¶
Initializes a PLProofWriter object. |
Module Contents¶
- class logitorch.pl_models.proofwriter.PLProofWriter(pretrained_model: str = 'google/t5-v1_1-large', learning_rate: float = None, weight_decay=0.1)[source]¶
Bases:
lightning.pytorch.LightningModuleInitializes a PLProofWriter object.
- Args:
pretrained_model (str, optional): The name or path of the pretrained model to use. Defaults to “google/t5-v1_1-large”. learning_rate (float, optional): The learning rate for the optimizer. Defaults to None. weight_decay (float, optional): The weight decay for the optimizer. Defaults to 0.1.
- configure_optimizers()[source]¶
Configures the optimizer and scheduler for training.
- Returns:
Tuple[List[Optimizer], List[Dict[str, Any]]]: The optimizer and scheduler.
- forward(x, y) transformers.modeling_outputs.SequenceClassifierOutput[source]¶
Performs a forward pass of the model.
- Args:
x: The input data. y: The target data.
- Returns:
SequenceClassifierOutput: The output of the model.
- predict(context: str, question: str, num_beams: int = 5, max_length: int = 120, device: str = 'cpu')[source]¶
Generates predictions for the given context and question.
- Args:
context (str): The context for the prediction. question (str): The question for the prediction. num_beams (int, optional): The number of beams for beam search decoding. Defaults to 5. max_length (int, optional): The maximum length of the generated sequence. Defaults to 120. device (str, optional): The device to use for prediction. Defaults to “cpu”.
- Returns:
The generated predictions.
- training_step(train_batch: Tuple[Dict[str, torch.Tensor], torch.Tensor], batch_idx: int) torch.Tensor[source]¶
Performs a training step.
- Args:
train_batch (Tuple[Dict[str, torch.Tensor], torch.Tensor]): The batch of training data. batch_idx (int): The index of the batch.
- Returns:
torch.Tensor: The loss value.