nlpmodels/utils/elt/gpt_batch.py
def make_std_mask(self, tgt: torch.Tensor, pad: int) -> torch.Tensor:
        """
        Create a mask to hide padding and future words for src sequence.

        Args:
            tgt (torch.Tensor): The target input of (batch_size,context_window) size.
            pad (int): pad index to identify the padding in each sequence.

        Returns:
            output matrix of size (batch_size,max_seq_length,max_seq_length)
            size with masked values for target sequence [True,False]
        """
        # 3D tensor necessary for attention, add in the middle.
        tgt_mask = (tgt != pad).unsqueeze(1)
        seq_size = tgt.size(1)
        # subsequent mask built off sequence size
        tgt_mask = tgt_mask & self.subsequent_mask(seq_size).to(self._device)
        return tgt_mask

        Create a mask to hide padding and future words for src sequence.

        Args:
            tgt (torch.Tensor): The target input of (batch_size,context_window) size.
            pad (int): pad index to identify the padding in each sequence.

        Returns:
            output matrix of size (batch_size,max_seq_length,max_seq_length)
            size with masked values for target sequence [True,False]
        
Create a mask to hide padding and future words for src sequence.
Create a mask to hide padding and future words for src sequence .
def make_std_mask(self, tgt: torch.Tensor, pad: int) -> torch.Tensor:
        tgt_mask = (tgt != pad).unsqueeze(1)
        seq_size = tgt.size(1)
        tgt_mask = tgt_mask & self.subsequent_mask(seq_size).to(self._device)
        return tgt_mask
def make_std_mask ( self , tgt : torch . Tensor , pad : int ) -> torch . Tensor : tgt_mask = ( tgt != pad ) . unsqueeze ( 1 ) seq_size = tgt . size ( 1 ) tgt_mask = tgt_mask & self . subsequent_mask ( seq_size ) . to ( self . _device ) return tgt_mask
Create a mask to hide padding and future words for src sequence.
Create a mask to hide padding and future words for src sequence .
"""
        Create a mask to hide padding and future words for src sequence.

        Args:
            tgt (torch.Tensor): The target input of (batch_size,context_window) size.
            pad (int): pad index to identify the padding in each sequence.

        Returns:
            output matrix of size (batch_size,max_seq_length,max_seq_length)
            size with masked values for target sequence [True,False]
        """ # 3D tensor necessary for attention, add in the middle. # subsequent mask built off sequence size
output matrix of size (batch_size,max_seq_length,max_seq_length)
size with masked values for target sequence [True,False]
output matrix of size ( batch_size max_seq_length max_seq_length ) size with masked values for target sequence [ True False ]
self
tgt
torch.Tensor
The target input of (batch_size,context_window) size.
The target input of ( batch_size context_window ) size .
pad
int
pad index to identify the padding in each sequence.
pad index to identify the padding in each sequence .