logitorch.models.ruletaker ========================== .. py:module:: logitorch.models.ruletaker Classes ------- .. autoapisummary:: logitorch.models.ruletaker.RuleTaker Module Contents --------------- .. py:class:: RuleTaker(num_labels: int = 2) Bases: :py:obj:`torch.nn.Module` RuleTaker is a PyTorch module for rule-based question answering using the Roberta model. Args: num_labels (int): The number of labels for classification. Default is 2. Attributes: num_labels (int): The number of labels for classification. encoder (RobertaForMultipleChoice): The Roberta model for multiple choice tasks. config (RobertaConfig): The configuration of the Roberta model. classifier (RobertaClassificationHead): The classification head of the Roberta model. tokenizer (RobertaTokenizer): The tokenizer for the Roberta model. Methods: forward(x, y=None): Performs forward pass of the RuleTaker model. predict(context, question, device="cpu"): Predicts the answer label for a given context and question. Initializes a RuleTaker instance. Args: num_labels (int): The number of labels for classification. Default is 2. .. py:method:: forward(x, y=None) Performs forward pass of the RuleTaker model. Args: x (dict): The input dictionary containing the context and question. y (Tensor): The target labels. Default is None. Returns: outputs (tuple): A tuple containing the logits and other outputs. .. py:method:: predict(context: str, question: str, device: str = 'cpu') -> int Predicts the answer label for a given context and question. Args: context (str): The context for the question. question (str): The question to be answered. device (str): The device to run the prediction on. Default is "cpu". Returns: pred (int): The predicted answer label. .. py:attribute:: classifier .. py:attribute:: config .. py:attribute:: encoder .. py:attribute:: num_labels :value: 2 .. py:attribute:: tokenizer