Featurizes a Query. Args: query: a Query instance. fmt: can be either 'dict' or 'bert_inputs'. Default is 'dict'. Returns: If fmt is 'dict', a dict with the following structure: input_ids: [query_seq_len] int32 Tensor input_mask: [query_seq_len] int32 Tens
(self, query, fmt='dict')
| 164 | |
| 165 | @profile.profiled_function |
| 166 | def featurize_query(self, query, fmt='dict'): |
| 167 | """Featurizes a Query. |
| 168 | |
| 169 | Args: |
| 170 | query: a Query instance. |
| 171 | fmt: can be either 'dict' or 'bert_inputs'. Default is 'dict'. |
| 172 | |
| 173 | Returns: |
| 174 | If fmt is 'dict', a dict with the following structure: |
| 175 | input_ids: [query_seq_len] int32 Tensor |
| 176 | input_mask: [query_seq_len] int32 Tensor |
| 177 | segment_ids: [query_seq_len] int32 Tensor |
| 178 | If fmt is 'bert_inputs', a BertInputs object. |
| 179 | """ |
| 180 | query_mask_features = self.mask_query(query) |
| 181 | |
| 182 | bert_inputs = bert_format( |
| 183 | input_seqs=[query_mask_features['token_ids_after_masking']], |
| 184 | max_seq_len=self.query_seq_len, |
| 185 | cls_id=self.tokenizer.cls_id, |
| 186 | sep_id=self.tokenizer.sep_id) |
| 187 | |
| 188 | return self._reformat_bert_inputs(bert_inputs, fmt) |
| 189 | |
| 190 | @profile.profiled_function |
| 191 | def featurize_document(self, doc, fmt='dict'): |
no test coverage detected