MCPcopy Create free account
hub / github.com/THUDM/GLM / make_masked_data

Method make_masked_data

blocklm_utils.py:160–170  ·  view source on GitHub ↗
(self, tokens, loss_masks, attention_mask, block_spans, rng, task='bert')

Source from the content-addressed store, hash-verified

158 return mask_spans
159
160 def make_masked_data(self, tokens, loss_masks, attention_mask, block_spans, rng, task='bert'):
161 position_ids = np.arange(len(tokens), dtype=np.long)
162 targets = copy.deepcopy(tokens)
163 mask_id = self.tokenizer.get_command('MASK').Id
164 mlm_masks = np.zeros(len(tokens), dtype=np.long)
165 for start, end in block_spans:
166 for idx in range(start, end):
167 tokens[idx] = mask_id
168 mlm_masks[start: end] = 1
169 loss_masks = loss_masks * mlm_masks
170 return tokens, targets, loss_masks, position_ids
171
172 def make_block_data(self, tokens, loss_masks, attention_mask, block_spans, rng, task='bert'):
173 text_length = len(tokens)

Callers 1

generate_blank_dataMethod · 0.95

Calls 1

get_commandMethod · 0.80

Tested by

no test coverage detected