MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / _shift_right_t5

Method _shift_right_t5

seq2seq/utils.py:313–318  ·  view source on GitHub ↗
(self, input_ids)

Source from the content-addressed store, hash-verified

311 return batch
312
313 def _shift_right_t5(self, input_ids):
314 # shift inputs to the right
315 shifted_input_ids = input_ids.new_zeros(input_ids.shape)
316 shifted_input_ids[..., 1:] = input_ids[..., :-1].clone()
317 shifted_input_ids[..., 0] = self.pad_token_id
318 return shifted_input_ids
319
320 def _encode(self, batch) -> Dict[str, torch.Tensor]:
321 batch_encoding = self.tokenizer.prepare_seq2seq_batch(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected