minicons.supervised module

class minicons.supervised.SupervisedHead(model_name: str, device: Optional[str] = 'cpu')

Bases: object

(Under construction) Implements the supervised head class to facilitate behavioral analyses of model outputs.

encode(inputs: Union[str, List[str]], return_tensors: Optional[str] = 'pt') Dict

Encodes batch of inputs to the supervised model to return an encoded format to be passed to the model.

Parameters
  • inputs (Union[str, List[str]]) – batch of inputs to be encoded by the model.

  • return_tensors (Optional[str]) – returned tensor format. Default ‘pt’

Returns

Dictionary of encoded input.

logits(inputs: Union[str, List[str]], probs: bool = True, verbose: bool = False) Union[torch.Tensor, Dict]

Runs inference on the model and returns logits for each label depending on the supervised task on which the model was trained on.

Parameters
  • inputs (Union[str, List[str]]) – batch of inputs to be encoded by the model.

  • probs (bool) – specifies whether to return probabilities.

  • verbose (bool) – specifies if the label names should be revealed in the output (if they exist).

Returns

Either a torch tensor consisting of the model outputs or a dictionary consisting of {label: probability}.