meerqat.models.rr module#

class meerqat.models.rr.BertReRanker(config)[source]#

Bases: BertPreTrainedModel

As described in [1].

Almost like BertForSequenceClassification without dropout, and pooling from [CLS] token.

References

forward(*args, **kwargs)[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class meerqat.models.rr.ECAReRanker(config, **kwargs)[source]#

Bases: ECAEncoder

Like BertReRanker with a ECA backbone instead of BERT

forward(*args, return_dict=True, **kwargs)[source]#
Parameters:
  • text_inputs (dict[str, torch.LongTensor]) – usual BERT inputs, see transformers.BertModel

  • face_inputs (dict[str, torch.FloatTensor]) –

    {

    “face”: (batch_size, n_images, n_faces, face_dim), “bbox”: (batch_size, n_images, n_faces, bbox_dim), “attention_mask”: (batch_size, n_images, n_faces)

    }

  • image_inputs (dict[str, dict[str, torch.FloatTensor]]) –

    {

    model: {

    ”input”: (batch_size, n_images, image_dim) “attention_mask”: (batch_size, n_images)

    }

    }

class meerqat.models.rr.FlamantReRanker(config, **kwargs)[source]#

Bases: FlamantModel

Like BertReRanker with a Flamant backbone instead of BERT

forward(*args, return_dict=True, **kwargs)[source]#
Parameters:
  • text_inputs (dict[str, torch.LongTensor]) – usual BERT inputs, see transformers.BertModel

  • face_inputs (dict[str, torch.FloatTensor]) –

    {

    “face”: (batch_size, n_images, n_faces, face_dim), “bbox”: (batch_size, n_images, n_faces, bbox_dim), “attention_mask”: (batch_size, n_images, n_faces)

    }

  • image_inputs (dict[str, dict[str, torch.FloatTensor]]) –

    {

    model: {

    ”input”: (batch_size, n_images, image_dim) “attention_mask”: (batch_size, n_images)

    }

    }