MCPcopy Create free account
hub / github.com/google-research/language / _reformat_bert_inputs

Method _reformat_bert_inputs

language/realm/featurization.py:151–163  ·  view source on GitHub ↗

Reformats BERT input features.

(self, bert_inputs, fmt)

Source from the content-addressed store, hash-verified

149 }
150
151 def _reformat_bert_inputs(self, bert_inputs, fmt):
152 """Reformats BERT input features."""
153 if fmt == 'bert_inputs':
154 return bert_inputs # No reformatting necessary.
155 elif fmt == 'dict':
156 # This is the format expected by the original BERT code.
157 return {
158 'input_ids': bert_inputs.token_ids,
159 'input_mask': bert_inputs.mask,
160 'segment_ids': bert_inputs.segment_ids,
161 }
162 else:
163 raise ValueError('Invalid format: {}'.format(fmt))
164
165 @profile.profiled_function
166 def featurize_query(self, query, fmt='dict'):

Callers 2

featurize_queryMethod · 0.95
featurize_documentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected