Skip to content

Commit

Permalink
docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
dakinggg committed Oct 15, 2023
1 parent 81fff0f commit 0159ec3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions llmfoundry/data/text_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ def build_text_dataloader(


def get_tokens_per_batch_func(pad_token_id: int) -> Callable[[Batch], int]:
"""Returns a callable that counts the number of tokens in a batch.
Args:
pad_token_id (int): The id of the padding token.
Returns:
Callable[[Batch], int]: A callable that counts the number of tokens in a batch.
"""

def get_num_samples_in_batch(batch: Batch) -> int:
if not isinstance(batch, Mapping) or 'input_ids' not in batch:
raise ValueError(
Expand Down

0 comments on commit 0159ec3

Please sign in to comment.