MCPcopy Create free account
hub / github.com/AnswerDotAI/ModernBERT / _create_batch

Method _create_batch

src/sequence_packer.py:348–365  ·  view source on GitHub ↗

Returns a batch of packed sequences with its cumulative seq length information. Or else, returns None if it cannot build a full outgoing batch. Must mutate self.buffer to remove the sequences that are packed into the batch. Returns: (out_batch,cumulati

(self)

Source from the content-addressed store, hash-verified

346
347 @abstractmethod
348 def _create_batch(self) -> Optional[tuple[np.ndarray, list[list[int]]]]:
349 """
350 Returns a batch of packed sequences with its cumulative seq length information.
351
352 Or else, returns None if it cannot build a full outgoing batch.
353
354 Must mutate self.buffer to remove the sequences that are packed into the batch.
355
356 Returns:
357 (out_batch,cumulative_seq_len):tuple[torch.tensor, list[list[int]]]
358 where:
359 - out_batch is a tensor of shape (out_batch_size, out_pseq_len);
360 - cum_seq_lens is a list of lists, where the outer list is of len out_batch_size,
361 and each inner list is of varying length, and contains the start positions of
362 every seq in the pseq, and the end position of the last seq in the pseq. This end
363 position is necessary to communicate if any padding tokens were added.
364 """
365 pass
366
367
368@njit

Callers 1

_generate_batchesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected