logitorch.pl_models.ruletaker

Classes

PLRuleTaker

Initializes the PLRuleTaker module.

Module Contents

class logitorch.pl_models.ruletaker.PLRuleTaker(learning_rate: float = 1e-05, weight_decay: float = 0.1, num_labels: int = 2)[source]

Bases: lightning.pytorch.LightningModule

Initializes the PLRuleTaker module.

Args:

learning_rate (float): The learning rate for the optimizer. Default is 1e-5. weight_decay (float): The weight decay for the optimizer. Default is 0.1. num_labels (int): The number of labels for the RuleTaker model. Default is 2.

configure_optimizers()[source]

Configures the optimizer and scheduler for training.

Returns:

The optimizer and scheduler.

forward(x, y)[source]

Performs a forward pass of the PLRuleTaker module.

Args:

x: The input data. y: The target labels.

Returns:

The output of the model.

predict(context: str, question: str, device: str = 'cpu') int[source]

Predicts the label for a given context and question.

Args:

context (str): The context. question (str): The question. device (str): The device to use for prediction. Default is “cpu”.

Returns:

The predicted label.

training_step(train_batch: Tuple[Dict[str, torch.Tensor], torch.Tensor], batch_idx: int) torch.Tensor[source]

Performs a training step.

Args:

train_batch: The batch of training data. batch_idx (int): The index of the batch.

Returns:

The training loss.

validation_step(val_batch: Tuple[Dict[str, torch.Tensor], torch.Tensor], batch_idx: int) None[source]

Performs a validation step.

Args:

val_batch: The batch of validation data. batch_idx (int): The index of the batch.

learning_rate = 1e-05[source]
model[source]
weight_decay = 0.1[source]