MCPcopy Create free account
hub / github.com/huggingface/transformers / trim_seq2seq_batch

Method trim_seq2seq_batch

examples/seq2seq/utils.py:122–125  ·  view source on GitHub ↗
(batch, pad_token_id)

Source from the content-addressed store, hash-verified

120
121 @staticmethod
122 def trim_seq2seq_batch(batch, pad_token_id):
123 y = trim_batch(batch["decoder_input_ids"], pad_token_id)
124 source_ids, source_mask = trim_batch(batch["input_ids"], pad_token_id, attention_mask=batch["attention_mask"])
125 return source_ids, source_mask, y
126
127 def collate_fn(self, batch) -> dict:
128 input_ids = torch.stack([x["input_ids"] for x in batch])

Callers 1

_generative_stepMethod · 0.80

Calls 1

trim_batchFunction · 0.85

Tested by

no test coverage detected