(batch, pad_id, args)
| 277 | |
| 278 | |
| 279 | def pad_batch(batch, pad_id, args): |
| 280 | |
| 281 | context_lengths = [] |
| 282 | for tokens in batch: |
| 283 | context_length = len(tokens) |
| 284 | if context_length < args.seq_length: |
| 285 | tokens.extend([pad_id] * (args.seq_length - context_length)) |
| 286 | context_lengths.append(context_length) |
| 287 | return batch, context_lengths |
| 288 | |
| 289 | |
| 290 | def get_token_stream(model, context_tokens): |
no test coverage detected