MCPcopy Index your code
hub / github.com/THUDM/GLM / process_batch

Function process_batch

tasks/seq2seq/evaluate.py:234–247  ·  view source on GitHub ↗

Process batch and produce inputs for the model.

(batch, args)

Source from the content-addressed store, hash-verified

232
233
234def process_batch(batch, args):
235 """Process batch and produce inputs for the model."""
236 if 'mask' in batch:
237 # finetune SQuAD
238 batch['attention_mask'] = batch.pop('mask')
239 batch['position_id'] = batch.pop('position')
240 tokens = batch['text'].long().cuda()
241 attention_mask = batch['attention_mask'].long().cuda()
242 position_ids = batch['position_id'].long().cuda()
243 if tokens.dim() == 3:
244 tokens = tokens.squeeze(1)
245 attention_mask = attention_mask.squeeze(1)
246 position_ids = position_ids.squeeze(1)
247 return tokens, attention_mask, position_ids
248
249
250class DecoderEvaluater:

Callers 2

evaluateMethod · 0.70
evaluateMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected